參考文檔:
1.uni 安卓設置 UrlSchemes: https://ask.dcloud.net.cn/article/409
2.uni ios 設置 UrlSchemes: https://ask.dcloud.net.cn/article/64
安卓
在manifest.json文件的"plus"->"distribute"->"google"下添加schemes節點數據如下:
"plus": { "distribute": { "google": { "schemes": [ "test" // 設置 ], //... },
蘋果
在manifest.json的"app-plus"->"distribute"->"ios"節點下添加urltypes數據:
"plus": { "distribute": { "apple": { "urltypes": [ { "urlidentifier":"com.xxx.test", "urlschemes": [ "test" ] } ], //... }, //... }, //... },
h5 打開app ,百度瀏覽器不支持
openAPP(){ if(this.model === 'iPhone'){ if(this.searchCode){ window.location.href = "test://"+this.searchCode + '//' +this.inviteCode }else{ window.location.href = "test://" } setTimeout(function(){ // 蘋果下載地址 window.location.href = 'itms-apps://itunes.apple.com/app/蘋果id' },2000) }else{ if(this.searchCode){ window.location.href = "test://" + this.searchCode +'//'+ this.inviteCode }else{ window.location.href = "test://" } setTimeout(function(){ // app 下載地址 },2000) } },
APP 獲取urlscheme啟動傳遞的參數
var args= plus.runtime.arguments; if(args){ // 處理args參數,如直達到某新頁面等 }
清除urlscheme啟動傳遞的參數(一定要這樣,不然清不掉)
plus.runtime.arguments = null plus.runtime.arguments = ''