You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ionic应用deep links功能异常 点击跳转App Store而非唤起应用如何解决?

问题根因

你遇到的问题由两个原因导致:

  1. iOS 9及以上系统对自定义URI Scheme的查询做了权限限制,没有在Info.plist的LSApplicationQueriesSchemes字段中声明的Scheme,调用canLaunch会直接返回false/抛出错误,直接走到catch分支跳转应用商店
  2. 现有代码逻辑没有对canLaunch返回的布尔值做判断,部分场景下canLaunch不会抛出错误,只会返回无法唤起的布尔值,你没有对该状态做对应跳转商店的处理

修复步骤

1. 配置iOS URI Scheme查询白名单

在你项目的ios/App/App/Info.plist文件中添加如下配置,声明你要查询的exiapp Scheme:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>exiapp</string>
</array>

2. 修正业务代码逻辑

补全canLaunch返回结果的判断逻辑,同时保留异常分支的兜底跳转:

popover.onDidDismiss()
    .then(async (decision) => {
        if (exiStatus.status === 'registered' && decision.data) {
            const options: AppLauncherOptions = {}
            if (this.platform.is('ios')) {
                options.uri = 'exiapp://referral'
            } else {
                options.packageName = 'com.iprescribeexercise.app.android.iPrescribe'
            }
            this.appLauncher.canLaunch(options)
                .then((canLaunch: boolean) => {
                    if (canLaunch) {
                        // 设备已安装应用直接唤起
                        this.appLauncher.launch(options);
                    } else {
                        // 设备未安装应用跳转商店
                        if (this.platform.is('ios')) {
                            window.open('https://apps.apple.com')
                        } else {
                            window.open('https://play.google.com/store/apps/details?id=com.iprescribeexercise.app.android.iPrescribe')
                        }
                    }
                })
                .catch((error: any) => {
                    // 接口调用异常兜底跳转商店
                    if (this.platform.is('ios')) {
                        window.open('https://apps.apple.com')
                    } else {
                        window.open('https://play.google.com/store/apps/details?id=com.iprescribeexercise.app.android.iPrescribe')
                    }
                });
        }
    })

可选优化

如果你的应用适配了iOS通用链接(Universal Link),可以直接用通用链接替代自定义Scheme,不需要配置查询白名单,唤起成功率更高,也不会弹出系统确认弹窗。

内容的提问来源于stack exchange,提问作者naresh mandloi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 14:24:03