Hi Everyone,
I’m attempting to use the save method of the KeychainTouchId ionic-native component.
When running in the iOS simulator, the following error is returned:
⚡️ [log] - Error in Success callbackId: TouchID190698072 : TypeError: callback.success.apply is not a function. (In 'callback.success.apply(null, args)', 'callback.success.apply' is undefined)
⚡️ [error] - {"line":273,"column":71,"sourceURL":"user-script:27"}
Seems to imply that the method is expecting a callback function, but this does not match the ionic documentaion.
Note all other methods of the plugin work as expected.
Any help appreciated.
Ionic:
Ionic CLI : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.2.3
@angular-devkit/build-angular : 0.901.11
@angular-devkit/schematics : 9.1.9
@angular/cli : 9.1.11
@ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.2.1
@capacitor/core : 2.2.1
Utility:
cordova-res : 0.15.1
native-run : not installed
System:
NodeJS : v10.16.0 (/usr/local/Cellar/node@10/10.16.0/bin/node)
npm : 6.9.0
OS : macOS Mojave
This is how I’m using it in my component.
import { KeychainTouchId } from '@ionic-native/keychain-touch-id/ngx';
.
.
.
constructor(
.
.
.
private kechainTouchId: KeyChainTouchId,
.
.
.
) { }
.
.
.
async presentBiometricSetupOffer() {
const actionSheet = await this.actionSheetController.create({
header: 'Setup Biometric Authentication.',
buttons: [
{
text: 'Setup',
handler: () => {
const credentials = {
instance: this.instance,
username: this.username,
password: this.password,
selectedURI: this.selectedURI
};
this.keychainTouchId.save('com.feenics.mobile.key', JSON.stringify(credentials), true)
.then(() => {
this.biometricsConfigured = true;
this.presentToast('Credentials saved. Reloading.');
setTimeout(() => {
location.assign(this.apiService.originURI);
}, 2000);
})
.catch((error: any) => console.log('Key save error: ', error));
}
},
{
text: 'Later',
role: 'cancel',
handler: () => {
location.assign(this.apiService.originURI);
}
},
{
text: 'Never',
handler: () => {
this.keychainTouchId.has('com.feenics.mobile.key')
.then(() => {
this.keychainTouchId.delete('com.feenics.mobile.key')
.then(() => {
this.biometricsConfigured = false;
console.log('Keychain key deleted.');
})
.catch(error => console.log('Keychain verify failure: ', error));
})
.catch((error: any) => {
console.log('keychainTouchId.has error: ', error);
});
localStorage.setItem('refusedBiometrics', 'true');
location.assign(this.apiService.originURI);
}
}
]
});
await actionSheet.present();
}