Firebase AppInvite已被弃用,我必须更新代码。
图书馆:com.google.firebase:firebase-invites:11.6.2
代码:
private void handleDeepLink() {
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(mActivity)
.enableAutoManage(mActivity, this)
.addApi(AppInvite.API)
.build();
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, mActivity, false)
.setResultCallback(
new ResultCallback<AppInviteInvitationResult>() {
@Override
public void onResult(@NonNull AppInviteInvitationResult result) {
if (result.getStatus().isSuccess()) {
Intent intent = result.getInvitationIntent();
sDeepLink = AppInviteReferral.getDeepLink(intent);
//...
} else {
//...
}
}
});
}
您知道新代码吗?
答案 0 :(得分:2)
根据文档,这是获取深层链接的新代码。
文档:https://firebase.google.com/docs/dynamic-links/android/receive
代码:
FirebaseDynamicLinks.getInstance()
.getDynamicLink(mActivity.getIntent())
.addOnSuccessListener(mActivity, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
Uri deepLink;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
if (deepLink != null) {
//...
}
}
}
})
.addOnFailureListener(mActivity, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
//...
}
});