1、生物認證
生物認證 是一種基于個體獨特生理或行為特征進行身份驗證的技術,廣泛應用于安全、金融、醫療等領域。
小程序目前暫時只支持指紋識別認證。
2、查詢支持的生物認證方式
獲取本機支持的 SOTER 生物認證方式,文檔
onLoad(options) {wx.checkIsSupportSoterAuthentication({success(res) {console.log(res);},fail(err) {console.log(err)}})
}
返回:
{"supportMode": ["fingerPrint"]
}
- fingerPrint,指紋識別
- facial,人臉識別
- speech,聲紋識別(暫未支持)
3、檢查是否錄入生物信息
獲取設備內是否錄入如指紋等生物信息的接口,文檔
onLoad(options) {wx.checkIsSoterEnrolledInDevice({checkAuthMode: 'fingerPrint',success(res) {console.log(res.isEnrolled)},fail(err) {console.log(err);}})
}
返回:
{"isEnrolled": true,"errMsg": null
}
- isEnrolled,是否已錄入信息
- errMsg,錯誤信息
4、使用生物認證
開始 SOTER 生物認證,文檔
onLoad(options) {wx.startSoterAuthentication({requestAuthModes: ['fingerPrint'],challenge: '123456',authContent: '請用指紋解鎖',success(res) {console.log(res);},fail(err) {console.log(err);}})
}
- requestAuthModes,請求使用的可接受的生物認證方式
- challenge,挑戰因子為調用者為此次生物鑒權準備的用于簽名的字符串關鍵識別信息,將作為 resultJSON 的一部分,供調用者識別本次請求。例如:如果場景為請求用戶對某訂單進行授權確認,則可以將訂單號填入此參數。
- authContent,驗證描述,即識別過程中顯示在界面上的對話框提示內容
效果:
返回:
{"authMode": "fingerPrint","resultJSON": {},"resultJSONSignature": "P3jGJOtJNnxnNbw==","errCode": 0,"errMsg": "startSoterAuthentication:ok"
}
如您在閱讀中發現不足,歡迎留言!!!