最近在项目需要一个功能就是,在cordova app中点击然后直接跳转到微信的公众号中让用户关注公众号,但后来发现微信sdk现在不支持这个接口了,无奈只能实现点击打开微信这个功能了。
本来是使用下面这种方式实现的
try { if (typeof cordova != undefined) { let ref = cordova.InAppBrowser.open( "wechat://", "_system", "location=no" ); } } catch (e) { alert("唤起失败") }但是发现在安卓中没有作用,所以我们这里采用了另一种方式:
a href="weixin://" class="action-callweixin"打开微信/a
然后注意在app的config.xml文件中加上
access launch-external="yes" origin="weixin:*" /
allow-navigation href="*" /
allow-intent href="*" /
后面两行如果不加的话在ios中会报“weixin://” url not set 错误的














