Cordova Android端DeepLink可打开App但关联事件未触发求助
Cordova Android DeepLink问题:应用可唤起但关联事件不触发
- 现象:通过DeepLink能唤起应用,但配置的关联事件无法执行;网页链接也无法触发DeepLink
- 核心错误日志:Logcat中PluginManager模块警告
exec() call to an unknown plugin: UniversalLinks. - 异常点:
res/config.xml中未自动添加该插件的feature(其他插件会自动添加)
已做配置及操作
1. 插件安装
安装了e-imaxina/cordova-plugin-deeplinks 1.1.1版本插件
2. config.xml配置
<universal-links> <host name="my.website.com" scheme="https"> <path url="/deep-link" event="loginExterno" /> </host> </universal-links> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="*" /> <access origin="*" /> <allow-navigation href="*" />
3. 前端代码(index.js的OnDeviceReady事件中)
universalLinks.subscribe('loginExterno', function (eventData) { alert("deepLink - 1"); }); universalLinks.subscribe(null, function (eventData) { alert("deepLink - 2"); });
4. AndroidManifest.xml Intent过滤器配置
<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:host="my.website.com" android:scheme="https" android:path="/deep-link"/> </intent-filter>
5. 测试命令
执行adb命令可唤起应用,但事件无响应:
adb shell am start -W -a android.intent.action.VIEW -d https://my.website.com/deep-link io.cordova.hellocordova
环境信息
- Cordova版本:12.0.0 (cordova-lib@12.0.1)
- 已安装插件列表:
- cordova-plugin-deeplinks 1.1.1 "Cordova Deeplinks Plugin"
- cordova-plugin-device 2.1.0 "Device"
- cordova-plugin-dialogs 3.0.0-dev "Notification"
- cordova-plugin-inappbrowser 5.0.0 "InAppBrowser"
- cordova-plugin-nativestorage 2.3.2 "NativeStorage"
- cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
- cordova-plugin-splashscreen 6.0.1 "Splashscreen"
- cordova-plugin-statusbar 3.0.0 "StatusBar"
- cordova-plugin-vibration 3.1.1 "Vibration"
- cordova-plugin-x-socialsharing 6.0.4 "SocialSharing"
- es6-promise-plugin 4.2.2 "Promise"
- 测试设备:Samsung Galaxy A22 - Android 13 - minSdkVersion 21
- 开发方式:纯原生HTML、JS、CSS,未使用Ionic
内容的提问来源于stack exchange,提问作者SuNcO
相关产品推荐
相关产品推荐

