Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase dynamic link doesn't invoke dynamic link on first launch after install

I have read a lot of question on stackoverflow but none of them answer the question.

I am trying to set up dynamic links so that a link will deep link the user to the app if they already have it installed and the play store if they don't. I expect the link to survive the play store installation process and be sent to the launcher activity with the link. The dynamic link works when the app is already installed. However, when the app is not installed, it sends the user to the play store but the dynamic link does not survive the installation process. I have read that the "Open" button is supposed to change to "Continue" when the user is sent to the play store with a dynamic link, but when I do it, it still says "Open". Here is my activity in AndroidManifest.xml for the activity

    <activity
        android:name="com.xxx.xxx.xxx.xxx"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.SplashScreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="yyy.page.link"
                android:scheme="http" />
            <data
                android:host="yyy.page.link"
                android:scheme="https" />
        </intent-filter>
    </activity>

The Activity is as follows:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ia_login);

        checkIfReferral();
    }

    private void checkIfReferral(){
    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;
                    Log.w(TAG, "FBDL we have a dynamic link");
                    if (pendingDynamicLinkData != null) {
                        deepLink = pendingDynamicLinkData.getLink();
                    }else{
                        Log.w(TAG, "FBDL pending dynamic Link Data is null , returning " );
                        return;
                    }
                    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
                    Boolean ret1 = (user==null);
                    Boolean ret2 = (deepLink !=null);
                    Boolean ret3 = (deepLink.getBooleanQueryParameter("invitedby", false));
                    referrerUid = deepLink.getQueryParameter("invitedby");                   
                    if (deepLink != null && deepLink.getBooleanQueryParameter("invitedby", false)) {
                        referrerUid = deepLink.getQueryParameter("invitedby");
                        createAnonymousAccountWithReferrerInfo(referrerUid);
                    }
                }
            }).addOnFailureListener(this, new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.w(TAG, "FBDL we couldnt receive dynamic link");
        }
    });

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if(user !=null) {
        Log.w(TAG, "FBDL if use != null");
        userRecord = FirebaseDatabase.getInstance().getReference()
                .child("users")
                .child(user.getUid());
    }
}

I have added the dynamic link. It is the same as declared in the manifest file. I have added SHA 256 generated from the release key that i signed the app with. The app is on Google Play Store production release.

Please let me know what the mistake is.

Why don't I see "continue" on the Google Play store when dynamic link took me there?

like image 229
Mike Avatar asked Oct 12 '20 17:10

Mike


People also ask

How do Firebase dynamic links work?

Dynamic Links are smart URLs that allow you to send existing and potential users to any location within your iOS or Android app. They survive the app install process, so even new users see the content they're looking for when they open the app for the first time. Dynamic Links are no-cost forever , for any scale.

How do I create a dynamic link in Firebase?

You create a Dynamic Link either by using the Firebase console, using a REST API, iOS or Android Builder API, or by forming a URL by adding Dynamic Link parameters to a domain specific to your app. These parameters specify the links you want to open, depending on the user's platform and whether your app is installed.

Do Firebase dynamic links expire?

As far as I know, dynamic links work for as long as your firebase project active. I used some dynamic links more than one year after they were created. I didn't see anything about any time limits in the documentation.


2 Answers

You have to add an auto-verified intent filter to the Activity that will handle the Dynamic Link, setting the host to your project's Dynamic Links domain as found in the Firebase console. In the AndroidManifest.xml:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:host="yyy.page.link" android:scheme="http"/>
    <data android:host="yyy.page.link" android:scheme="https"/>
</intent-filter>

Note that the android:host must be set to your Dynamic Links domain, and not the domain of your deep link.

More informations here

like image 61
ismail alaoui Avatar answered Oct 19 '22 21:10

ismail alaoui


I see that App Links is enabled in your implementation of Firebase Dynamic Links. App Links require the Dynamic Link domain to be added in the Manifest intent-filter, but Dynamic Links still needs to have intent-filter for the deep links that the app will receive. By adding deep links in the intent-filter, not only that it makes FDL to work with the app, but it also ensures that the app will still work if a regular link is used.

If you're still having issues after this, you can file a ticket here https://firebase.google.com/support. You may need to share the Dynamic Link and the Firebase SDK version you're using.

like image 33
Omatt Avatar answered Oct 19 '22 21:10

Omatt