H5+app項目,在HBuilderX中設置
詳情參考官方 https://ask.dcloud.net.cn/article/64
給h5+app設置scheme值,作用:在其它app和h5頁面中啟動該app,如下
在manifest.json文件的"plus"->"distribute"->"apple"下添加urltypes節點數據如下:
"plus": { "distribute": { "apple": { "urltypes": [ { "urlidentifier":"com.xxx.test", //值域說明:urlidentifier為標識,可自定義,格式為反向域名格式;
//urlschemes為要指定的scheme值,字符串數組,使用小寫字母,可設置多個。 比如設置為test,那么其他App呼起你的app的scheme協議就是test://。保存后提交App雲端打包生效
"urlschemes": [ "test" ] } ], //...
}, //...
}, //...
}, //...
uni-app項目
把上面的urltypes節點數據放到manifest.json的"app-plus"->"distribute"->"ios"節點下
如需設置應用訪問白名單
作用:允許當前app訪問(查詢是否安裝、直接打開)其它app白名單列表
參考文檔:https://ask.dcloud.net.cn/article/434
打開app的協議設置好后就可以通過以下方式打開
window.location.href = 'test://abc' abc為參數可以不傳
如果想打開app指定頁面需要在5+ APP中處理urlscheme啟動傳遞的參數
詳情參考官方 https://ask.dcloud.net.cn/article/64
document.addEventListener('plusready',function(){ checkArguments(); },false); // 判斷啟動方式
function checkArguments(){ console.log("plus.runtime.launcher: "+plus.runtime.launcher); var args= plus.runtime.arguments; if(args){ // 處理args參數,如打開新頁面等
} } // 處理從后台恢復
document.addEventListener('newintent',function(){ console.log("addEventListener: newintent"); checkArguments(); },false);