上頭給了一個需求,要通過一個網(wǎng)頁的超鏈接啟動本地app,但是在網(wǎng)上查了相關(guān)資料都是通過自定義URL Schemes協(xié)議來啟動app,代碼如下:
//android端xml配置
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="test" android:host="gw" android:pathPrefix="/open" android:port="8888"/>
</intent-filter>
//js代碼:
var t;
var config = {
scheme_IOS: 'appB://',
scheme_Adr: 'test://gw:8888/open',
download_url: "http://mb.sseinfo.com/ComInfoServer/ssegwappdownload.jsp",
timeout: 600
};
function startApp(){
var startTime = Date.now();
if(isWeiXin()){
alert("請?jiān)跒g覽器中打開!");
}else{
var iframe = document.createElement("iframe");
if(checkOS()){
iframe.src=config.scheme_Adr;
}else{
iframe.src=config.scheme_IOS;
}
iframe.style.display = "none";
document.body.appendChild(iframe);
t = setTimeout(function() {
var endTime = Date.now();
if (!startTime || endTime - startTime < config.timeout + 20) {
window.location = config.download_url;
} else {
}
}, config.timeout);
window.onblur = function() {
clearTimeout(t);
}
}
}
那么問題就是,除了Chrome可以,在qq,UC瀏覽器中都會在瀏覽器內(nèi)部啟動app,在手機(jī)后臺進(jìn)程中并沒有啟動新的app,整個app界面直接是嵌入在瀏覽器
添加回答
舉報
0/150
提交
取消