checkIsSoterEnrolledInDevice,安卓,ios兼容-返回值、await
发布于 5 年前 作者 guiying81 3304 次浏览 来自 官方Issues

https://developers.weixin.qq.com/miniprogram/dev/api/open-api/soter/wx.checkIsSoterEnrolledInDevice.html

设备: Android9 一加5 iPhone XSmax ios13.3.1

微信版本 均为 version 7.0.11

基础库均为 2.10.2

1.wx.checkIsSoterEnrolledInDevice(obj)

回调结果 安卓 isEnrolled 返回 true/false IOS 返回 1/0


2.iPhone XS MAX 调用,fingerPrint facial 均为 1,当wx.startSoterAuthentication 为 fingerPrint 却出错,

就不应该出现 fingerPrint 也为1 的情况;


3.异步调用 async await

function checkAuthMode(){
  // 判断 checkAuthMode 支持情况
  // 遍历,当支持面容 则 优先使用 面容 后者覆盖前者
  return new Promise(async(resolve,reject)=>{
    let authMode = '';
    let msg = ''
    let arr = [{ auth: 'fingerPrint', name: '指纹' }, { auth: 'facial', name: '面容' },  { auth: 'speech', name: '声纹' }]
    for(let item of arr){
      let obj = { checkAuthMode: item.auth }
      const { isEnrolled } = await wx.checkIsSoterEnrolledInDevice(obj)
      .catch(e=>{
        console.log(e);
      })
      console.log(item,isEnrolled)
      if (isEnrolled) {
        authMode = item.auth;
        msg = item.name;
      }
    }
    if(authMode && msg) resolve({authMode,msg});
    else reject(new Error('不支持任何生物识别'))
  })
}

IOS: 逻辑正常执行,await wx.checkIsSoterEnrolledInDevice(obj) 未出现任何问题,for of循环正常;

Android 9:逻辑跑不通,await wx.checkIsSoterEnrolledInDevice(obj) for of 逻辑暂停

--- 原由: 1.Android 调用 wx.checkIsSoterEnrolledInDevice(obj)时,isEnrolled 为false 走到的是 fail回调(经过测试);

而 ios走的是 success回调

2.领悟,不要完全信任 增强编译,还是该自己 将模块 promise 化

1 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部