Skip to main content

my.bioMetrics.keyExists

bioMetrics.keyExists

my.bioMetrics.keyExists là API để kiểm tra thiết bị đã có lưu sẵn cặp key đề cập ở JSAPI my.bioMetrics.createKey. Nếu thiết bị đã có sẵn cặp key này, chúng ta ko cần phải tạo thêm.

Quét mã để trải nghiệm

Xem code mẫu trên Tini Studio

Demo

Trải nghiệm thử với trình giả lập bên dưới

Khả dụng: Hỗ trợ từ version 1.96.7 trở lên.

API Params

Thuộc tínhKiểu dữ liệuMô tả
successFunctionCallback function khi việc kiểm tra thành công
failFunctionCallback function khi việc kiểm tra thất bại
completeFunctionCallback function bất kể thành công hay thất bại

Giá trị trong success callback

Khi việc gọi API thành công, framework sẽ trả về payload là 1 biến boolean để biết cặp key đã tồn tại hay không.

Sample Code

index.xml
<view>
<block-header title="Usage" description="Use Biometrics to authenticate with server" />
<view class="block-content">
<view class="page-section-btns">
<button type="primary" onTap="createKey">Create Key Pair</button>
<button type="primary" onTap="keyExists">Check Key Exists</button>
<button type="primary" onTap="deleteKey">Delete Key</button>
</view>
</view>
<view class="block-content">
<view class="page-section-btns">
<button type="primary" onTap="createSignature">Generate Signature</button>
</view>
</view>
</view>
index.js
Page({
keyExists() {
my.bioMetrics.keyExists({
success: (isExist) => {
my.alert({
title: 'Success',
content: keyExists ? 'Key is exist' : 'No key found'
});
},
fail: (res) => {
my.alert({ title: 'Fail', content: JSON.stringify(res) });
}
});
}
});