I've made a dynamic link for users to share some contents in my app.
The link is working when I click a link in an HTML page using href
tag on Android device.
It means, if the app is not installed, go to Play Store, else opening the app and I could receive deep link address.
But when the link is exactly same on other places like a facebook messenger or email etc. I click the link, then it's not working.
It's always redirected to Play Store even if my app is already installed.
What's the problem?
My code is here.
.java for receiving deep link
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(AppInvite.API)
.build();
boolean autoLaunchDeepLink = false;
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
.setResultCallback(
new ResultCallback<AppInviteInvitationResult>() {
@Override
public void onResult(@NonNull AppInviteInvitationResult result) {
if (result.getStatus().isSuccess()) {
// Extract deep link from Intent
Intent intent = result.getInvitationIntent();
String deepLink = AppInviteReferral.getDeepLink(intent);
Log.e("sf", "### deep link : " + deepLink );
} else {
Log.d("asdf", "getInvitation: no deep link found.");
}
}
});
intent part of activity in AndroidManifest.xml
<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="mycode.app.goo.gl/"
android:scheme="https"
android:pathPattern=".*" />
</intent-filter>
dynamic link
https://mycode.app.goo.gl/?link=web page address
&al=my custom scheme for sharing
&apn=my android app's package name
We have implemented Firebase Dynamic Links according to this documentation https://firebase.google.com/docs/dynamic-links/ and they are working properly in all cases except of Facebook and Facebook Messenger app.
First we generate a dynamic link to our app:
Builder builder = new Builder()
.scheme("https")
.authority("winged-guild-133523.appspot.com")
.appendPath("share")
.appendQueryParameter("query", query);
Then we generate the long dynamic link:
Builder builder = new Builder()
.scheme("https")
.authority("zkkf4.app.goo.gl")
.appendPath("")
.appendQueryParameter("link", deepLink)
.appendQueryParameter("apn", "com.mydomain.myapp");
Then we exchange the long dynamic link with a short link at https://firebasedynamiclinks.googleapis.com/v1/shortLinks and share it using intent:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, null));
If we share this link using Facebook app:
If we share this link using Facebook Messenger app:
So I see three problems here:
Do anyone have any idea what is going on an how to solve those issues?
PS: Although this is irrelevant because the deep link handling in the app is working properly this is our manifest intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:host="winged-guild-133523.appspot.com"/>
<data android:host="www.winged-guild-133523.appspot.com"/>
<data android:pathPattern="/share.*"/>
</intent-filter>