從h5 喚起 APP 【uni-app】


參考文檔:

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 = ''

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM