https://firebase.google.com/docs/dynamic-links/android/receive
states that
Calling getDynamicLink() retrieves the link and clears that data
I kept a dirty hack by taking a global url and comparing it next time with new url , It's not perfect but it's the best I came up with .
var previousDeepLink:String?=null //take it as global and static
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener() {
@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();
}
if(previousDeepLink==deepLink?.toString()){
return@OnSuccessListener
}
previousDeepLink=deepLink?.toString()
// 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);
}
});