I try to save contact using ionic-native/contacts plugin, it works on all android versions except android 8, the app is stopped and closed. This is my code which is the same of ionic framework example:
SaveToContact(phone, name) {
try {
let contact: Contact = this.contacts.create();
contact.name = new ContactName(null, name, ‘’);
contact.phoneNumbers = [new ContactField(‘mobile’, phone)];
this.global.presentToast(‘Will Save!’),
contact.save().then(
() => this.global.presentToast(‘Contact saved!’),
(error: any) => this.global.presentToast(‘Error saving contact: No Permission’)
);
} catch (e) {
this.global.presentToast(e);
}
I used android-26 to build apk, and these are the versions for ionic-native/contacts plugin
“@angular/core”: “5.0.3”
“ionic-angular”: “3.9.2”
“cordova-plugin-contacts”: “^3.0.1”
“@ionic-native/contacts”: “^4.7.0”
I also put the plugin object in the provider array in the app module, but still the app crash.