firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.25k stars 572 forks source link

160610872: Dynamic link data not cleared after being read. #1755

Closed aidanas closed 1 year ago

aidanas commented 4 years ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

As stated in official documentation HERE

Calling getDynamicLink() retrieves the link and clears that data so it is only processed once by your app.

However when testing on a basic HelloWorld test app once users click on an deep link and the app is started (or brought to foreground if meanwhile was running in the background) then repeated calls to getDynamicLink() always resolve to an app link.

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Relevant Code:

            @Override
            public void onClick(View view) {
                Log.d(TAG, "Click received" );
                Activity activity = getActivity();
                final Intent intent = activity.getIntent();
                FirebaseDynamicLinks.getInstance()
                        .getDynamicLink(intent) // This should clear link data after reading once!
                        .addOnSuccessListener(activity, 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;
                                Log.d(TAG, "pendingDynamicLinkData:" + pendingDynamicLinkData );

                                if (pendingDynamicLinkData != null) {
                                    deepLink = pendingDynamicLinkData.getLink();
                                    Log.d(TAG, "deepLink:" + deepLink );
                                }
                            }
                        })
                        .addOnFailureListener(activity, new OnFailureListener() {
                            @Override
                            public void onFailure(@NonNull Exception e) {
                                Log.w(TAG, "getDynamicLink:onFailure", e);
                            }
                        });
            }
google-oss-bot commented 4 years ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

MeghaB commented 4 years ago

Internally tracking via b/160610872

Hey @aidanas - to help us investigate this further - does the getDynamicLink still return the fdl once the app is relaunched? Trying to determine which of the following cases you're running into:

  1. Click FDL -> Open App -> all calls the getDynamicLink returns the fdl -> close app -> re-open app -> getDynamicLink is empty or
  2. Click FDL -> Open App -> all calls the getDynamicLink returns the fdl -> close app -> re-open app -> getDynamicLink returns the original fdl
artakka commented 2 years ago

Having a similar issue

rmazajev commented 1 year ago

Same issue here. Using firebase-bom:31.1.1

My case is like this:

Click on FDL -> App opens -> getDynamicLink gets the deeplink (expected result) -> minimize app -> Click on FDL -> App opens -> getDynamicLink gets the deeplink (expected result) -> minimize app -> resume the app from recents -> getDynamicLink gets the deeplink (wrong result) -> minimize app -> resume the app from recents -> getDynamicLink gets the deeplink (wrong result)

So in my case I'm getDynamicLink returns deeplink on resume, but only if I click on FDL second time. Second time app was in background.

Update: After a bit more investigation, it may be that issue is related to intent data/extras being restored if application was started from recent list. Found some related issue here. I changed my logic to call FirebaseDynamicLinks.getInstance().getDynamicLink(intent) only if activity was not opened from history by checking if Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY flag is not set. I'm not sure how reliable this solution is, but it solved my issue from what I have tested.

isamotiuc commented 1 year ago

Having the same issue. In documentation is said that:

You must call getDynamicLink() in every activity that might be launched by the link, even though the link might be available from the intent using getIntent().getData(). Calling getDynamicLink() retrieves the link and clears that data so it is only processed once by your app.

But I receive this link each time, I have link handler in onReasume method

argzdev commented 1 year ago

Hi folks, we'd like to inform you that the Firebase Dynamic Links service will be shutdown on August 25, 2025. In the meantime, only critical or security issues will be fixed in the SDK.

More at https://firebase.google.com/support/dynamic-links-faq