【问题标题】:Android deeplink path, pathPrefix or pathPattern not workingAndroid 深层链接路径、pathPrefix 或 pathPattern 不起作用
【发布时间】:2021-06-12 08:38:14
【问题描述】:

我正在尝试使 Android 深度链接仅适用于特定网址,例如:

所以http://books.com/about 一直链接到网页

AndroidManifest.xml 中的此配置有效并在我的应用程序中打开正确的页面。问题是这匹配 books.com 上的每一页

<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="@string/custom_url_scheme" />

    <data android:scheme="https" android:host="books.com" />
</intent-filter>

当我把数据部分改成:

<data android:scheme="https" android:host="books.com" android:path="/book/nice-book-1" />

<data android:scheme="https" android:host="books.com" android:pathPrefix="/book" />

<data android:scheme="https" android:host="books.com" android:pathPattern="/book/..*" />

只匹配 /book 后跟一个 slug,它不能全部工作。

我已经在 Stackoverflow 上发现了许多类似的问题,但它们要么已经过时,要么无法处理 url 与 slug 一起使用的情况。

是否有人在仅将几个 url 与 slug 匹配时遇到同样的问题?

【问题讨论】:

  • 我也有同样的问题,android:pathPrefix="/ar/" 不起作用

标签: android ionic-framework deep-linking capacitor


【解决方案1】:

我花了很长时间才弄清楚这一点。所以我会回答我自己的问题以节省其他人宝贵的时间。

事实证明,当通过 Android Studio 在设备上运行 Android 应用时

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

是唯一可行的路径。

使用时:

<data android:scheme="https" android:host="books.com" android:path="/book/nice-book-1" />

<data android:scheme="https" android:host="books.com" android:pathPrefix="/book" />

这些仅在您的设备上使用 SIGNED 版本的应用时有效。这可能是因为在您的assetlinks.json 中有一个sha256_cert_fingerprints,只有在使用签名的应用程序时才能验证。

【讨论】:

    猜你喜欢
    • 2016-03-20
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 2014-10-01
    • 2020-09-21
    • 2019-01-23
    • 2014-09-08
    • 1970-01-01
    相关资源
    最近更新 更多