Ionic 2 native contacts (White Screen)

I have tried to run the code on different devices and still can Not pass the blank white screen!

If I remove contacts import, everything works fine, but with the contacts code in it, whole program stucks on the load.

Please, do you have Any Suggestions?

this is my code:

home.ts
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { Contacts, Contact, ContactField, ContactName } from ‘@ionic-native/contacts’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
constructor(public navCtrl: NavController,private contacts: Contacts) { }

showButton(){
alert(‘activated’);
let contact: Contact = this.contacts.create();
contact.name = new ContactName(null, ‘Chat’, ‘Contact’);
contact.phoneNumbers = [new ContactField(‘mobile’, ‘123456789’)];
contact.save().then(
() => console.log(‘Contact saved!’, contact),
(error: any) => console.error(‘Error saving contact.’, error)
);
}
}

home.html

Show Contact Page…


<button ion-button color=“secondary” (click)=“showButton()”>Show Conact

System information:
Cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed

I have tested it on the android and iphone, both with the same results …

anyone? Someone?

An error of some sort would be nice. Have you checked the logs?

Did you add Contacts as a provider in your app module?

thank you for your reply Sigmund.

I am quite new to ionic development.

Unfortunately, I see no logs at all, not even alert, as it freezes on the load process.

I run the project using: ionic run android

No, I have not added it as a provider. I will give you feedback as soon as I test it.

Adding as a provider solved the Problem & I marked your response as a Solution.

Thanks a lot!!!

You actually saved my time and nerves …