android - 带有 android :autoVerify ="true" - never verified at installation, 默认应用程序链接的 Intent 过滤器不起作用

标签 android deep-linking branch.io

我在我的 Android 应用程序中使用 branch.io SDK,并希望我的应用程序成为 Android 6 上分支链接的默认处理程序,如所述 here (Android 指南)和 here (Branch.io 指南)

这是我在 AndroidManifest.xml 中的 Activity 声明:

    <activity android:name="com.mypackage.MyActivity"
              android:launchMode="singleTask">
        <intent-filter tools:node="merge" android:autoVerify="true">
            <data android:scheme="@string/url_scheme" android:host="open"/>
            <data android:scheme="https"
                  android:host="@string/branch_io_host"
                  android:pathPrefix="@string/branch_io_path_prefix"/>
            <data android:scheme="http"
                  android:host="@string/branch_io_host"
                  android:pathPrefix="@string/branch_io_path_prefix"/>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
        </intent-filter>
    </activity>

但是,当我在我的设备上安装构建时,当我单击具有正确主机和路径的链接时,我仍然会看到选择器对话框。读完这篇文章后 extensive guide on app linking ,我相信这是因为我的设备从不验证我的应用程序的 Intent 过滤器。例如。当我从 Play 商店安装 Twitter 应用程序时,我在 LogCat 中看到这些消息:

03-24 15:04:27.231: D/IntentFilterVerificationReceiver(16965): Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
03-24 15:04:27.248: I/IntentFilterIntentService(16965): Verifying IntentFilter. verificationId:2 scheme:"https" hosts:"twitter.com www.twitter.com ads.twitter.com" package:"com.twitter.android".
03-24 15:04:30.134: I/IntentFilterIntentService(16965): Verification 2 complete. Success:true. Failed hosts:.

但是当我安装我的应用程序时,我没有看到这样的消息。我尝试了发布和调试版本,尝试将其上传到 Play 商店的 Alpha 测试并从那里安装,结果相同。为什么 Android 不验证我的 Intent 过滤器?

最佳答案

通过将此数据标签移动到单独的 Intent 过滤器中解决了这个问题:

<data android:scheme="@string/url_scheme" android:host="open"/>

这就是 AndroidManifest 现在的样子:

<activity android:name="com.mypackage.MyActivity"
          android:launchMode="singleTask">
    <intent-filter tools:node="merge" android:autoVerify="true">
        <data android:scheme="https"
              android:host="@string/branch_io_host"
              android:pathPrefix="@string/branch_io_path_prefix"/>
        <data android:scheme="http"
              android:host="@string/branch_io_host"
              android:pathPrefix="@string/branch_io_path_prefix"/>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
    </intent-filter>
    <intent-filter>
        <data android:scheme="@string/url_scheme" android:host="open"/>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
    </intent-filter>
</activity>

来自 IntentFilter 的消息现在按预期显示在日志中。

关于android - 带有 android :autoVerify ="true" - never verified at installation, 默认应用程序链接的 Intent 过滤器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36211104/

相关文章:

Android Studio 无法启动 git,虽然实际上可以

android - URLConnection getInputStream() 和 HttpEntity getContent() 之间的区别

android - 在深度链接上获得正确的引荐来源应用程序

Android 深度链接无法启动应用程序

android - 即使安装了应用程序,Android 中的 Branch.io 深层链接也会打开 Play 商店

android - 如何检测Android WebRTC轨道结束

angular - Ionic2 深度链接段可选参数

android - 使用 Branch 创建用户邀请码的正确方法是什么?

ios - 使用深度链接启动时应用程序未按预期启动

android - Firebase 集成错误 : Google Play Services out of date