Xamarin Forms应用无法通过链接唤起问题求助
Xamarin Forms 应用链接唤起问题排查方案
安卓端排查
- 核对IntentFilter配置完整性,需包含
VIEW动作、DEFAULT和BROWSABLE类别,同时匹配目标链接的scheme、host和路径前缀,示例配置:
<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="amaar-app.com" /> <data android:pathPrefix="/ar/unit/" /> </intent-filter>
- 确保
android:autoVerify="true"属性已添加到所有处理唤起的Activity(包括SplashActivity),这是验证assetlinks.json的必要配置。 - 检查SplashActivity是否正确传递Intent至MainActivity,示例逻辑:
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // 传递唤起链接的Intent到MainActivity var intent = new Intent(this, typeof(MainActivity)); intent.PutExtras(Intent.Extras); intent.SetData(Intent.Data); StartActivity(intent); Finish(); }
- 用adb命令直接测试唤起:
adb shell am start -W -a android.intent.action.VIEW -d "http://amaar-app.com/ar/unit/207" com.your.package.name
能唤起则说明应用配置正常,问题出在浏览器或Web端;不能唤起则根据终端错误信息定位。
iOS端排查
- 确认关联域名格式正确,应为
applinks:amaar-app.com,不要添加http/https前缀或路径。 - 验证apple-app-site-association文件:需放在Web服务器的
.well-known目录下,无后缀,内容示例:
{ "applinks": { "details": [ { "appIDs": ["你的TeamID.你的BundleID"], "paths": ["/ar/unit/*"] } ] } }
- 确保应用为Ad Hoc或App Store签名安装(调试签名的应用可能无法触发通用链接),且测试需使用真机,模拟器不支持通用链接验证。
- 检查Info.plist中是否开启了
NSAllowsArbitraryLoads(若Web端使用http链接),但优先建议使用https以符合苹果通用链接要求。
Web端配置验证
- 核对assetlinks.json的路径和内容,需放在
https://amaar-app.com/.well-known/目录下,示例:
[ { "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.your.package.name", "sha256_cert_fingerprints": ["应用签名的SHA256指纹"] } } ]
- 访问
https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://amaar-app.com&relation=delegate_permission/common.handle_all_urls,确认返回结果包含正确的应用信息。 - 确保Web服务器支持HTTPS(安卓autoVerify仅支持HTTPS链接验证),http链接仅适用于本地测试场景。
共享项目排查
- 确认
OnAppLinkRequestReceived方法正确重写并添加日志排查是否触发:
protected override void OnAppLinkRequestReceived(Uri uri) { System.Diagnostics.Debug.WriteLine($"收到唤起链接:{uri.ToString()}"); // 此处添加页面导航逻辑 base.OnAppLinkRequestReceived(uri); }
若应用能唤起但方法未触发,需检查安卓端Intent传递或iOS端通用链接的路由配置。
通用测试注意事项
- 不要直接在浏览器地址栏输入链接跳转,需通过标签、短信、笔记等场景点击链接触发唤起。
- 测试不同浏览器的兼容性,部分浏览器需通过链接验证后才会触发应用唤起。
内容的提问来源于stack exchange,提问作者raito tec
相关产品推荐
相关产品推荐

