@nativescript/secure-storage
Version:
Secure Storage NativeScript plugin
43 lines • 1.19 kB
JavaScript
import { ApplicationSettings } from '@nativescript/core';
export class SecureStorageCommon {
constructor() {
this.isFirst = ApplicationSettings.getBoolean(SecureStorageCommon.IS_FIRST_RUN, true);
if (this.isFirst) {
ApplicationSettings.setBoolean(SecureStorageCommon.IS_FIRST_RUN, false);
}
}
isFirstRunSync() {
return this.isFirst;
}
isFirstRun() {
return new Promise((resolve, reject) => {
resolve(this.isFirstRunSync());
});
}
clearAllOnFirstRun() {
return new Promise((resolve, reject) => {
if (this.isFirstRunSync()) {
this.removeAll();
resolve(true);
}
else {
resolve(false);
}
});
}
clearAllOnFirstRunSync() {
try {
if (this.isFirstRunSync()) {
this.removeAllSync();
return true;
}
return false;
}
catch (e) {
console.log(e);
return false;
}
}
}
SecureStorageCommon.IS_FIRST_RUN = '__IS_FIRST_RUN__';
//# sourceMappingURL=common.js.map