Android:意图过滤器验证失败

2024-02-16

我的目标是让 Android 自动打开任何以test.touchwonders.com在我的应用程序中。我已将所需的文件放在我的服务器上:https://test.touchwonders.com/.well-known/assetlinks.json

这是我的清单的相关部分:

    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:name="com.justbrands.highstreet.pmelegend.PmeApplication">
    <activity
        android:name="com.highstreet.core.activity.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>


        <intent-filter android:autoVerify="true">
            <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="test.touchwonders.com" />
            <data android:host="www.test.touchwonders.com" />
        </intent-filter>

        <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:scheme="pme-legend"/>
        </intent-filter>

    </activity>
</application>

然而,在安装应用程序时,这是我在 logcat 中看到的输出:

06-27 09:48:43.267 6488-6488/? D/IntentFilterVerRcvr: Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
06-27 09:48:43.276 6488-8080/? I/IntentFilterIntentSvc: Verifying IntentFilter. verificationId:14 scheme:"https" hosts:"test.touchwonders.com www.test.touchwonders.com" package:"com.justbrands.highstreet.pmelegend.acceptance".
06-27 09:48:43.531 6488-8080/? I/IntentFilterIntentSvc: Verification 14 complete. Success:false. Failed hosts:test.touchwonders.com,www.test.touchwonders.com.

我的设备使用 Charles 代理,它允许您查看请求。我没有看到发送到 test.touchwonders.com 的请求很困难。我用了adb shell pm clear com.android.statementservice在安装之前,这应该清除缓存并强制重新获取 json。


事实证明问题不在我的应用程序中,而是在网站服务器上的 assetlinks.json 文件中。就我而言,问题是服务器响应的 MIME 类型不是application/json我真正的问题是我没有测试我的 assetlinks 文件的方法。我同时找到了一个:

参考https://developer.android.com/training/app-links/index.html#testing https://developer.android.com/training/app-links/index.html#testing

并使用测试网址

https://digitalassetlinks.googleapis.com/v1/statements:list?
source.web.site=https://<domain1>:<port>&
relation=delegate_permission/common.handle_all_urls
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android:意图过滤器验证失败 的相关文章

随机推荐