我已经设法让 App Linking 在 Android 上工作,它在打开指定的 url 时打开应用程序。
我正在打开 url https://fir-trial-66e3f.web.app/stripesub
但是它会询问我是否要使用应用程序或谷歌浏览器打开链接,选项为“仅一次”或“始终”。
我希望它在第一时间自动在应用中打开,而不询问用户。
我已尝试按照此处 ( https://stackoverflow.com/a/34360396/10222449 ) 的说明添加 android:autoVerify="true"
并验证了我的网站。
我不需要上传 json 文件,因为它会自动验证它,因为我使用与 firebase 项目所有者相同的谷歌帐户。
但是它仍然问同样的问题。
我正在使用带有 Capacitor 的 Ionic 应用程序,但我认为这与问题无关。
AndroidManifest.xml
<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="https"
android:host="fir-trial-66e3f.web.app"
android:pathPrefix="/stripesub" />
</intent-filter>
我使用的资源: https://developer.android.com/studio/write/app-link-indexing https://developer.android.com/training/app-links/index.html
最佳答案
即使它在 search.google.com 上自动验证了我,我仍然需要从 Android Studio 中生成 json 文件并复制到:myurl/.well-known/assetlinks.json。
为此,转到 Android Studio -> 工具 -> 应用链接助手 -> 第 3 步关联网站
由于行尾问题(我认为),我还需要将它复制并粘贴到记事本中,并且我在 json 的末尾放了一个回车符,否则它不起作用。
关于android - 如何在不要求用户第一次在浏览器或应用程序之间进行选择的情况下从链接打开 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59148831/