Firebase dynamic link, clear it after using once

前端 未结 3 704
孤城傲影
孤城傲影 2021-01-17 15:31

https://firebase.google.com/docs/dynamic-links/android/receive

states that

Calling getDynamicLink() retrieves the link and clears that data

3条回答
  •  醉话见心
    2021-01-17 16:27

    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);
            }
        });
    
                    
    

提交回复
热议问题