Need help resolving an issue regarding Ionic native plugin that reads device contacts


#1

Hi Team,

This is regarding a help I need with device contacts. Its something that is not mentioned anywhere in the documentation and that nobody seems to have faced earlier (so there is not much help available over the web which I can refer to). It would be very helpful to me if you have any information/knowledge about it and if you can spare some time to guide me through it.

I am working on an Ionic3-Angular4 project where we are reading device contacts.

The app that we are building has a requirement where a user can select a specific contact from his own device contact list and request our server to print and send a physical copy of book to the given contact. For this, we are required to validate the contact address and find out whether they have entered a valid full address. Which means the user should have saved Street Address, City, State, and Postal Code of a particular contact to whom he wishes to send a physical copy of a book.

However during extensive study of the contacts native plugin and the various android handsets that are available in market, we have found that not all devices give the user ability to save all fields(street address, state, postal code, and locality) separately. Most devices just have single field to enter address while in a few there are four different fields to save this information. We have also found that whether or not a device supports multi-field support, it always concatenates the entire address into a single field and it is available in formattedAddress. But we need our validation to be smart, meaning if the device supports multi-field address then it should check call fields and validate whether the address is valid or not, otherwise it should just validate if address is available in formattedAddress field and say whether a contact address is valid or not.

Additionally these days most users use third party apps and they have background sync enabled which pull contacts from them using these apps (LinkedIn, Google, facebook and so on). We’ve found when device auto-syncs contacts from these providers, at that time it sometimes pulls and stores info for all these fields separately. So even if the device doesn’t have multi-field support, there might be chances that we get values in these individual fields (state, postal code, and locality)

Considering all above scenarios, we are stuck at how to correctly validate the address. From what I have understood about the ionic native plugin so far, it looks like it does not provide us any ability to find out whether the device supports multi-field to store contacts or not. Neither there seems to be any field/property that the plugin exposes which will differentiate whether a contact was saved manually or whether it was auto-synced.

If there are any pointers that you can point us to do the correct validation in this case, then that would be very helpful. Would really appreciate any help you can provide.

Thank you.


#2

Did you look at the underlying Cordova plugin that the Ionic Native wrapper wraps?

How should this work? Can and does the native Contacts app know where the data comes from? Is this “state” somehow saved and accessible?