【发布时间】:2017-06-24 22:28:28
【问题描述】:
我正在这个github 项目之后创建一个深层/动态链接。
这是正在创建的链接:https://appcode.app.goo.gl/?link=http://example.com/-example&apn=com.abc.xxx&amv=16&ad=0&extraParameter=null
这是我用来分享的方法:
private void shareDeepLink(String deepLink) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Firebase Deep Link");
intent.putExtra(Intent.EXTRA_TEXT, deepLink);
itemView.getContext().startActivity(intent);
}
这是在我的应用程序的AndroidManifest.xml 文件中定义的intent-filters:
<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="example.com" android:scheme="http"/>
<data android:host="example.com" android:scheme="https"/>
</intent-filter>
这就是我尝试接收共享deep-link 的方式:
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();
final String deepLink = AppInviteReferral.getDeepLink(intent);
Log.d("deepLinkMainActivity", deepLink);
} else {
Log.d("getInvitation", "getInvitation: no deep link found.");
}
}
});
以下是注销的内容(收到深层链接):http://example.com/-example
您可以清楚地看到,我没有得到创建的确切深层链接,而是得到了它的修改版本。为什么?
我怎样才能获得创建和共享的完全相同的深层链接?
【问题讨论】:
-
你的意思是'Log.d("deepLinkMainActivity", deepLink);'这行输出'example.com/-example'?我认为这正是您提供的链接所期望的。你能说出你期望看到什么吗?
-
您的意图过滤器定义方案“https”,但您在链接中使用“http”。这是可能导致问题的一件事。
-
@diidu 我希望看到这整件事:
https://appcode.app.goo.gl/?link=http://example.com/-example&apn=com.abc.xxx&amv=16&ad=0&extraParameter=null -
这不是目的。在原始网址中,您甚至可以使用 &al= 为浏览器和应用程序提供不同的网址,您还可以提供后备链接。
-
@diidu 我想添加额外的查询参数,然后在收到链接时检索它们。怎么做?
标签: android firebase intentfilter deep-linking firebase-dynamic-links