Friday 16 October 2020

Firebse dynamic link doesnt invoke dynamic link on first lauch 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?



from Firebse dynamic link doesnt invoke dynamic link on first lauch after install

No comments:

Post a Comment