Ionic 3 , trying to get Contacts from device error

Hi
trying to use Contacts plugin in my dev android :

this.contacts.find([’*’]).then((contacts)=>{
console.log(JSON.stringify(contacts[0]));
});

keep getting this error

Cannot read property ‘split’ of undefined
at get (vendor.js:61937)
at getPlugin (vendor.js:61969)
at checkAvailability (vendor.js:81304)
at vendor.js:67675
at Contacts.find (vendor.js:67682)
at LoginPage.webpackJsonp.67.LoginPage.ionViewDidLoad (main.js:1736)
at ViewController._lifecycle (vendor.js:19797)
at ViewController._didLoad (vendor.js:19680)
at Tab.NavControllerBase._didLoad (vendor.js:54853)
at t.invoke (polyfills.js:3)

any idea?

I had the same problem. I fixed it with this steps:

  • Remove Ionic native plugin Contacts
  • Install Ionic native plugin Contacts at version 4.20 (the last one before version 5, which in my case was the one which crashed):
npm install @ionic-native/contacts@4.20.0

That’s all!

1 Like

Thanks Derekbaker, You saved my life

1 Like

Like a glooooooove!
thanks!

1 Like

This fix my issues as well. [Small rant] I have experience with JavaScript, jquery, angularjs and angular + everyone beloved typescript( plus several other coding languages) . However, developing in ionic feels like 50% coding and 50% finding out which version of X community library works. [rant done]. Be sure to update your app.module.ts with the correct import. I can’t tell you how many hours I wasted debugging code to find out I forgot to include the import file and provider item(“Contacts” or what ever you call it) it in the app.module.ts.

ionic cordova plugin add cordova-plugin-contacts

npm install @ionic-native/contacts@4.20.0

1 Like