IOS調用微信掃一掃scanQRCode報錯the permission value is offline verifying


問題

ios調用微信掃一掃scanQRCode報錯the permission value is offline verifying

document.getElementById("scanQRCode").onclick = function() {
  wx.scanQRCode({
    needResult: 1, // 默認為0,掃描結果由微信處理,1則直接返回掃描結果
    success: function(res) {
      alert("234");
      let data = res.resultStr; // 當needResult 為 1 時,掃碼返回的結果
      alert(data);
      alert(res.resultStr);
      window.open(data);
      //處理自己的邏輯
    }
  });
};

這種寫法寫在wx.ready里就會報錯the permission value is offline verifying,安卓下可以調用

基本解決方法

the permission value is offline verifying這個錯誤是因為config沒有正確執行,或者是調用的JSAPI沒有傳入config的jsApiList參數中。建議按如下順序檢查:

1.確認config正確通過。

2.如果是在頁面加載好時就調用了JSAPI,則必須寫在wx.ready的回調中。

3.確認config的jsApiList參數包含了這個JSAPI。

4.調用

 let _data = data.data.jsapi;
  wx.config({
    debug: false,
    appId: _data.appId,
    timestamp: _data.timestamp,
    nonceStr: _data.nonceStr,
    signature: _data.signature,
    jsApiList: ['scanQRCode']
  });
  wx.scanQRCode({
    desc: 'scanQRCode desc',
    needResult: 1, // 默認為0,掃描結果由微信處理,1則直接返回掃描結果,
    scanType: ['barCode'], // 可以指定掃二維碼還是一維碼,默認二者都有
    success: function (res) {
      alert(res.resultStr);
    }
  });

最終解決方法

當以上這些都沒有問題,created 里調的接口,分享的接口都通了,掃一掃的也是通的。我加了"checkJsApi"返回scanQRCode:true,但是還有有scanQRCode:the permission value is offline verifying的報錯

地址欄問題:push的跳轉不能被寫入ios微信瀏覽器的地址欄

處理:push跳轉改為window.loaction.href跳轉 ;window.loaction.href跳轉才能改變地址欄的變化,才能簽名成功

IOS調用微信掃一掃scanQRCode報錯the permission value is offline verifying


免責聲明!

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



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