I integrated my application with dynamic links from firebase successfully. But when I share a short link with SocialMetaTagParameters
and click on the link in messenger it opens the browser and it should redirected to my application, but it is entering in infinite loop in the browser.
I found similar issue created in google groups:
https://groups.google.com/forum/#!topic/firebase-talk/nOOcOwmxl58
This is my code to create short link:
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 to share the 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 code in 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 removed SocialMetaTagParameters, the link is working properly and when click on the link its redirected to my application