ERROR TypeError: Cannot read property 'then' of undefined while saving contact in IONIC 4

I want to save the contact to my phone book.
I followed the instructions at https://ionicframework.com/docs/native/contacts

Plugins I added :

ionic cordova plugin add call-number
npm install @ionic-native/call-number 
ionic cordova plugin add cordova-plugin-contacts
npm install @ionic-native/contacts

detail.html

<div class="call">
    <ion-buttons slot="primary">
        <ion-button size="small" (click)="save(memberData.contact_no,memberData.fname,memberData.lname)">
             Save Contact
             <ion-icon slot="end" name="phone-portrait"></ion-icon>
        </ion-button>
    </ion-buttons>
</div>

detail.ts


constructor(private contacts: Contacts) { }

save(number: string, firstName: string, lastName: string) {
    // alert(number + " " + firstName + " " + lastName);

    let contact: Contact = this.contacts.create();

    contact.name = new ContactName(null, firstName, lastName);
    contact.phoneNumbers = [new ContactField('mobile', number)];
    contact.save()
    .then(() => console.log('Contact saved!', contact),
      (error: any) => console.error('Error saving contact.', error))
    .catch(err => console.log('Catch : Error saving contact', err));
  } 

Error

common.js:290 Native: tried calling Contacts.create, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

MemberDetailPage.html:17 ERROR TypeError: Cannot read property ‘then’ of undefined

error

Cordova plugins are for real devices or simulators. If you don’t want to see these errors in web, run your code in:

if (this.platform.is('cordova')) {

    let contact: Contact = this.contacts.create();
    contact.name = new ContactName(null, firstName, lastName);
    contact.phoneNumbers = [new ContactField('mobile', number)];
    contact.save().then(() => console.log('Contact saved!', contact),
      (error: any) => console.error('Error saving contact.', error))
    .catch(err => console.log('Catch : Error saving contact', err));
}

Test your code in a device or simulator.