【问题标题】:Branch Deep Link does not open application分支深度链接不打开应用程序
【发布时间】:2016-10-11 15:21:40
【问题描述】:

我正在尝试将 Branch.io 深度链接 添加到我的应用程序中。我在应用程序中生成的链接重定向到网站而不是启动应用程序。我注意到,当我手动打开应用程序后,它会导航到我想通过 Deep Link 打开的 Activity。我通过 Fabric 工具包添加了 Branch.io,并按照 Fabric 中关于 深度链接路由 的分步教程进行操作。我的应用尚未出现在 Google Play 商店中。

这是我在网站上的配置(我还选中了选项:Always try to open appTest 仪表板顶部的模式)。我生成的链接也应该测试,因为我在BranchSDK: 响应/请求中看到了test key

http://imgur.com/a/mgLgu

AndroidManifest.xml

    <application
    android:name=".app.MainApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <meta-data
        android:name="io.branch.sdk.TestMode"
        android:value="true" />
    <meta-data
        android:name="io.branch.sdk.BranchKey"
        android:value="key_live_xxx" />
    <meta-data
        android:name="io.branch.sdk.BranchKey.test"
        android:value="key_test_xxx" />

    <activity
        android:name=".ui.main.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <data
                android:host="open"
                android:scheme="example" />
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>

构建.gradle

//...
applicationId "com.example"
//...
 compile('io.branch.sdk.android:library:2.4.3@aar') {
    transitive = true;
}

主应用程序

@Override
public void onCreate(){
    super.onCreate();
    Fabric.with(this);
    Branch.getAutoInstance(this);
}

如果需要,我可以添加更多代码 sn-p。

【问题讨论】:

    标签: android branch.io


    【解决方案1】:

    来自 Branch.io 的 Alex 在这里:

    因为当您在单击链接后手动启动应用程序时,它会导航到正确的活动,这意味着大部分您的配置是正确的。唯一似乎缺少的部分是触发您的应用实际启动的代码。

    在 Android 上,Branch 为此使用您的 URI 方案。也就是这段代码:

    <intent-filter>
        <data
            android:host="open"
            android:scheme="example" />
        <action android:name="android.intent.action.VIEW" />
    
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
    

    您需要用其他一些自定义字符串替换 android:scheme="example" 部分中的 example 值。然后确保在 Branch 仪表板的 Link Settings 部分中具有相同的字符串(加上 ://)。

    这应该足以让您在这里启动并运行。您可能还想查看我们的full developer documentation。 Fabric 指南是入门的好方法,但它们仅涵盖了 Branch 可用功能的一小部分!

    【讨论】:

    • 我将生成的链接中的https 更改为http,它开始工作了。
    • 好点。我不知道在scheme 字段中写什么。我建议你把文档中的example 字去掉,写一个更清晰的字符串,比如http://your.example.scheme/for.links,因为人们很困惑,不知道该写什么。谢谢!
    【解决方案2】:

    如果接受的解决方案不适合您,请尝试检查https://dashboard.branch.io/link-settings 顶部的Always try to open app 选项。

    【讨论】: