【问题标题】:App links not working应用链接失效
【发布时间】:2018-02-08 18:52:07
【问题描述】:

在我的应用程序中,我想使用应用程序链接。 为此,在我的 AndroidManifest.xml 中,我将活动定义为:

        <activity
        android:name="com.abc.xyz.DeepLinkActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.Transparent">

        <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:host="*.example.com"
                android:scheme="https"/>
            <data
                android:host="*.example.com"
                android:scheme="http"/>
        </intent-filter>
    </activity>

为此,我将assetlinks.json 定义为:

{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.abc.xyz",
    "sha256_cert_fingerprints": ["10:0C:0C:C2:78:EA:3B:DA:CA:A3:43:57:D1:8B:EE:62:15:E6:08:99:77:F1:F7:F1:DF:9E:DF:3C:92:04:B8:62"]
  }
}

其中指纹是默认的 android 调试密钥库指纹。

唯一需要指出的是,我们将 assetslink.json 托管在 https://www.example.com/.well-known/assetlinks.json 域而不是 https://example.com/.well-known/assetlinks.json 域。 会不会是原因。我似乎一直在遵循

上的所有指南
https://developer.android.com/training/app-links/verify-site-associations.html#request-verify

【问题讨论】:

  • 在应用安装期间使用SingleHostAsyncVerifier 过滤logcat 输出。它将显示 Android 为链接您的应用所采取的步骤,并会打印错误。
  • @SimonMarquis 谢谢,我可以看到 android 正在查找的 URL 及其状态。
  • 另一个链接我找到了一些关于这个问题的有用信息:medium.com/@kenkyee/…

标签: android deep-linking applinks


【解决方案1】:

正如here 指出的那样,android 不处理通配符,所以你应该改一下

<data
    android:host="*.example.com"
    android:scheme="https"/>

<data
    android:host="example.com"
    android:scheme="https"/>

您也可以使用https://developers.google.com/digital-asset-links/tools/generator 来测试网站是否验证了您的应用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-18
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    • 1970-01-01
    • 2015-10-14
    相关资源
    最近更新 更多