hsh*_*han 8 android firebase firebase-dynamic-links
我已经为用户创建了一个动态链接,可以在我的应用中分享一些内容.
当我href
在Android设备上使用标记单击HTML页面中的链接时,该链接正在运行.
这意味着,如果未安装该应用程序,请转到Play商店,否则打开应用程序即可收到深层链接地址.
但是当链接在Facebook信使或电子邮件等其他地方完全相同时,我点击链接,然后它就无法正常工作.
即使我的应用已安装,它也始终会重定向到Play商店.
有什么问题?
我的代码在这里.
.java用于接收深层链接
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.");
}
}
});
Run Code Online (Sandbox Code Playgroud)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>
Run Code Online (Sandbox Code Playgroud)动态链接
https://mycode.app.goo.gl/?link=&alweb page address
= my custom scheme for sharing
&apn =my android app's package name
我们已根据此文档https://firebase.google.com/docs/dynamic-links/实施了Firebase动态链接,除Facebook和Facebook Messenger应用外,它们在所有情况下都能正常运行.
首先,我们为我们的应用生成动态链接:
Builder builder = new Builder()
.scheme("https")
.authority("winged-guild-133523.appspot.com")
.appendPath("share")
.appendQueryParameter("query", query);
Run Code Online (Sandbox Code Playgroud)
然后我们生成长动态链接:
Builder builder = new Builder()
.scheme("https")
.authority("zkkf4.app.goo.gl")
.appendPath("")
.appendQueryParameter("link", deepLink)
.appendQueryParameter("apn", "com.mydomain.myapp");
Run Code Online (Sandbox Code Playgroud)
然后,我们通过https://firebasedynamiclinks.googleapis.com/v1/shortLinks上的短链接交换长动态链接,并使用intent共享它:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, null));
Run Code Online (Sandbox Code Playgroud)
如果我们使用Facebook应用分享此链接:
如果我们使用Facebook Messenger app分享此链接:
所以我在这里看到三个问题:
有谁知道如何解决这些问题?
PS:虽然这是无关紧要的,因为应用程序中的深层链接处理工作正常,这是我们的明显意图过滤器:
<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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3493 次 |
最近记录: |