Skip to main content

my.removeEncryptedStorage

removeEncryptedStorage

my.removeEncryptedStorage là api để xoá dữ liệu đã được lưu theo key

Lưu ý
  • Dữ liệu sẽ không bị mất khi ứng dụng bị xoá. Việc cài đè tiện ích không làm mất dữ liệu được lưu trữ.

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

API Params

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
keyStringKey của dữ liệu
configobjectCó thể bật chế độ xác thực trước khi lấy dữ liệu
successFunctionCallback khi dữ liệu được xoá thành công
failFunctionCallback khi xoá dữ liệu thất bại
completeFunctionCallback sau khi thực hiện việc xoá dữ liệu bất kể thành công hay thất bại

config payload

Thuộc tínhKiểu dữ liệuPlatformMô tả
accessControlstringios
- 'BIOMETRY_ANY_OR_DEVICE_PASSCODE'
- 'BIOMETRY_CURRENT_SET_OR_DEVICE_PASSCODE
- 'BIOMETRY_ANY'
authenticationPromptstringiosGhi chú khi người dùng mở khóa bằng sinh trắc học hoặc mật khẩu thiết bị.
servicestringiosTiêu chuẩn khi mã hoá, nếu khi lưu trữ người dùng set giá trị thì khi muốn lấy cần thêm đúng giá trị đã lưu trữ nếu không dữ liệu sẽ trả về null
authenticateTypestringios, androidLoại xác thực:
- DEVICE_PASSCODE_OR_BIOMETRICS (Xác thực bằng sinh trắc học hoặc mật mã thiết bị.)
- BIOMETRICS (Xác thực bằng phương pháp sinh trắc học (Touch ID hoặc Face ID).)
*Note: Default 'DEVICE_PASSCODE_OR_BIOMETRICS'

Sample Code

index.js
Page({
onRemoveData() {
my.removeStorage({
key: 'session',
config: {
authenticationPrompt: 'login with yourself',
accessControl: 'BIOMETRY_ANY_OR_DEVICE_PASSCODE'
},
success: function () {
my.alert({ content: 'Remove dữ liệu thành công' });
},
fail: function (res) {
my.alert({ content: res.errorMessage });
}
});
}
});