1.首先要在config.xml里配置自己的urlScheme,把下面代码拷贝到你的config.xml里。把comcsshsuqan换成你的自己的,建议自己好的记的名字
<config desc="appcanscheme" type="KEY">
<param platform="Android" name="appcanscheme" value="comcsshsuqan"/>
</config>
<config desc="comcsshsquan" type="URLSCHEME">
<urlScheme name="comcsshsquan" schemes="['comcsshsquan']"/>
</config>
2.上传改好的config.xml,在线打包。
3.然后在自己的服务器端写个html文件。把下面的comcsshsuqan换成你的,
如果要带参数可以这样传comcsshsuqan://?a=**&b=yyyy,在root页面添加方法uexWidget.onLoadByOtherApp(jsonData);
function startApp() { //定义startApp函数
这里的jsonData就是你传进去的参数,但是目前好像,引擎这方法不执行,待官方修复。
if (navigator.userAgent.match(/Chrome/)
&& navigator.userAgent.match(/Android/)) { //chrome浏览器
document.location = "comcsshsuqan://";
} else {
if (navigator.userAgent.match(/iPhone/)) {
window.location.href = "comcsshsuqan://";
} else {
var ifr = document.createElement('iframe');
ifr.src = "comcsshsuqan://";
ifr.style.display = 'none';
document.body.appendChild(ifr);
window.setTimeout(function() {
document.body.removeChild(ifr);
}, 500);
}
}
}
window.onload = function() {
startApp();
}
4.在手机浏览器上访问,你服务器的这个HTML就会自动调起你的APP了。
PS:微信里的浏览器是不支持的。。。
最近访客