Android Firebase Dynamic Links Not Working In Facebook Messenger Correctly

I have successfully integrated my application with dynamic links from firebase. But when I share a short link with SocialMetaTagParametersand click on the link in the messenger, it opens a browser and it should redirect to my application, but it enters an endless loop in the browser.

I found a similar problem created in google groups:

https://groups.google.com/forum/#!topic/firebase-talk/nOOcOwmxl58

This is my short link code:

Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
    .setLink(Uri.parse(link))
    .setDynamicLinkDomain(mContext.getString(R.string.firebaseAppCode))
    // Set parameters
    .setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
    .setIosParameters(new DynamicLink.IosParameters.Builder("com.xxxx.xxxx").build())
    .setSocialMetaTagParameters(
        new DynamicLink.SocialMetaTagParameters.Builder()
            .setTitle(title)
            .setDescription(description)
            .setImageUrl(Uri.parse(imageUrl))
            .build()
    )

    .buildShortDynamicLink()
    .addOnCompleteListener((Activity) mContext, new OnCompleteListener<ShortDynamicLink>() {
        @Override
        public void onComplete(@NonNull Task<ShortDynamicLink> task) {
            if (task.isSuccessful()) {
                // Short link created
                Uri shortLink = task.getResult().getShortLink();

                ShareApp(mContext, shortLink.toString());
            } else {
                Utils.ShowToast(mContext, "Sharing failed, Try again");
            }
        }
    });

This is my code for sharing a short dynamic link:

public static void ShareApp(Context mContext,String link) {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_TEXT,link);
    mContext.startActivity(Intent.createChooser(share, "Share..."));
}

This is the code in the manifest:

<activity
    android:name=".UI.Home.Consultants.ViewConsultantProfileActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="Profile"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme"
    android:windowSoftInputMode="stateHidden">
    <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="consultrustconsultant"
            android:scheme="http"/>
        <data
            android:host="consultrustconsultant"
            android:scheme="https"/>
    </intent-filter>
</activity>

Note:

if I deleted SocialMetaTagParameters, the link works correctly and when I click on the link it redirects to my application

+4

Source: https://habr.com/ru/post/1686419/


All Articles