Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Same deep link returned more than once. #72

Open
aidanas opened this issue Jul 3, 2020 · 0 comments
Open

Android: Same deep link returned more than once. #72

aidanas opened this issue Jul 3, 2020 · 0 comments

Comments

@aidanas
Copy link

aidanas commented Jul 3, 2020

The issue is present if app was not running in the background when an app link was clicked on and caused the app to be launched. In this case repeated calls to onDynamicLink() resolves to the same app link. Firebase Dynamic Links documentation states that dynamic link should be returned only once and then cleared. So this behaviour is inconsistent with the documentation and breaks the flow of an app. To make things even worse each call to onDynamicLink() returns link data with a different clicked timestamp so we have no way to track which links have already been processed on application level either.
The issue is not present on cases where an app link was clicked while application was still running in the background (not killed). In those cases only the first call to onDynamicLink() resolves with the link while subsequent ones do not.

Internally, it may look like its an issue with FirebaseDynamicLinks.getInstance().getDynamicLink(intent) since documentation states that:

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

However calling this method repeatedly still resolves with the link data, so data is not cleared as it should be.
We found that a temp patch for this would be to clear intent data at plugin level, at least until FB function does it, by calling intent.setData(null) in:

  private void respondWithDynamicLink(Intent intent) {
        this.firebaseDynamicLinks.getDynamicLink(intent)
                .continueWith(new Continuation<PendingDynamicLinkData, JSONObject>() {
                    @Override
                    public JSONObject then(Task<PendingDynamicLinkData> task) throws JSONException {
                        intent.setData(null);   // We clear clear intent data since getDynamicLink() did not.
                        PendingDynamicLinkData data = task.getResult();

                        JSONObject result = new JSONObject();
                        result.put("deepLink", data.getLink());
                        result.put("clickTimestamp", data.getClickTimestamp());
                        result.put("minimumAppVersion", data.getMinimumAppVersion());

                        if (dynamicLinkCallback != null) {
                            PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
                            pluginResult.setKeepCallback(true);
                            dynamicLinkCallback.sendPluginResult(pluginResult);
                        }

                        return result;
                    }
                });
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant