Reputation: 13367
I upgrade today google play service library to the last and now i have such error like :
warning: [deprecation] getInvitation(GoogleApiClient,Activity,boolean) in AppInviteApi has been deprecated
when i read the doc they say
This interface was deprecated. getInstance() is the main entry point for accessing Dynamic Link data and use getInvitation(com.google.firebase.dynamiclinks.PendingDynamicLinkData) for getting AppInvites data from the Dynamic Link data.
But i don't understand how i can convert my previous code :
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, mActivity, mAutoLaunchDeepLink)
.setResultCallback(
new ResultCallback<AppInviteInvitationResult>() {
@Override
public void onResult(AppInviteInvitationResult result) {
if (result.getStatus().isSuccess()) {
Intent intent = result.getInvitationIntent();
String deepLink = AppInviteReferral.getDeepLink(intent);
String invitationId = AppInviteReferral.getInvitationId(intent);
if (mAppInviteInvitationResultListener != null) mAppInviteInvitationResultListener.onSuccess(deepLink, invitationId);
}
else {
if (mAppInviteInvitationResultListener != null) mAppInviteInvitationResultListener.onError(2, 0);
}
mGoogleApiClient.unregisterConnectionCallbacks(InvitationResult);
mGoogleApiClient.unregisterConnectionFailedListener(InvitationResult);
mGoogleApiClient.disconnect();
}
});
to use now FirebaseAppInvite.getInvitation(...) ?
Upvotes: 0
Views: 213
Reputation: 191
Please read "handle Deep link " block on the following link:- https://firebase.google.com/docs/dynamic-links/android/receive
It has a below method which you can use to convert your code
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
}
// Handle the deep link. For example, open the linked
// content, or apply promotional credit to the user's
// account.
// ...
// ...
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "getDynamicLink:onFailure", e);
}
});
I hope it answers your question. Let me know if you need more clarification.
Upvotes: 3