Android App Links 配置问题求助

244 天前
 mqllin

有没有会 android 的大佬,给我整晕了 我配置了 AppLinks 一开始在我自己的服务器部署的,跳转一切正常。换到公司的(内网)发现跳转失败,当我再换回我的测试的发现我自己的也跳转不了了。一点链接就 浏览器 nginx 404 页面。不能跳到 APP 上。App Links Assistant 上验证工具也能通过,但就是没法跳转到 APP 。Android API 26 ( Android 8 ) 开发测试机 Pixel6 Android14 我认为配置了<intent-filter> 和在域名服务器上部署了证书后应该就能跳转才对。不知道是哪里错了。。 还有就是有没有比较好的 Android 开发社区,大佬们推荐一下! 下面是我的代码 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/logo"
        android:roundIcon="@mipmap/logo_round"
        android:label="@string/roll"
        android:supportsRtl="true"
        android:theme="@style/Theme.Hello"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/Theme.Hello">
            <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="https" />
                <data android:host="tw.eekda.com" />
                <data android:pathPrefix="/open" />
            </intent-filter>
        </activity>
    </application>

</manifest>

debug 证书地址: https://tw.eekda.com/.well-known/assetlinks.json

这是我跳转 url 的 Button 代码

openApp(){
const isAndroid = /Android/i.test(navigator.userAgent);
if (isAndroid) {
const uurl = `https://tw.eekda.com/open`;
// 尝试打开 APP 或者跳转到应用商店
window.location.href = uurl;
} else {
// 如果是其他平台(如 iOS )
alert("只支持 android")
}

},
4128 次点击
所在节点    Android
8 条回复
fuckshiter
244 天前
tools - applinks assistant 里面设置一下生成校验测试一下
mqllin
244 天前
@fuckshiter applinks assistant 校验是都能通过的,提示的 URL 点击也可以打开正常访问,但在浏览器中点击链接亦或是使用 App Links Assistant->Test on device or emulator 都不能正常跳转打开 APP 。浏览器会跳转到 nginx 404 。
我看了论坛有说 Android12 后需要把 data android:scheme 、host 、path 分开三个标签写的,我也尝试了对我没有效果。
fuckshiter
244 天前
@mqllin Link and Verif 通过后第四步那个个 Test App Links ,他会运行,然后他能打开到 app 就可以了。不行你可能要检查一下证书网络.更具体可以看这里 [验证 Android 应用链接]( https://developer.android.com/training/app-links/verify-android-applinks)
Lin0936
244 天前
可能是 app install 时的网络环境有问题?
fuckshiter
244 天前
看着是没问题,你看看上面官方链接里面的 adb shell 命令查看一下他的状态是不是对的。4 楼说的不也不是没有可能
mqllin
244 天前
@fuckshiter 刚刚我在你提及的这个网站( https://developers.google.com/digital-asset-links/tools/generator?hl=zh-cn )尝试验证了我的配置,通过了验证,然后我再一测试,现在 APP 能正常跳转了。但实际上我什么也没有做。。。正如我感觉什么也没有做突然就不能正常跳转了一下。总之给我的感觉是在 google 验证了一下,然后我就能跳转了。(我这是个本地 APP 并不会发布到 App Store )
mqllin
244 天前
@fuckshiter 十分感谢,虽然我没搞懂,但是你帮我解决了问题!
mqllin
244 天前
@fuckshiter 有一个新的问题,我的正式域名是内网解析的域名。目前怎么搞也还是无法跳转。请问 App Links 支持内网使用吗?会不会是因为 Google 的服务器无法验证内网的域名导致无法跳转呢?测试的设备上安装了内网证书,浏览器是可以访问到.well-known/assetlinks.json 文件的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/977291

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX