Contacts
$ ionic plugin add cordova-plugin-contacts
Repo: https://github.com/apache/cordova-plugin-contacts
Access and manage Contacts on the device.
Requires plugin: cordova-plugin-contacts
For full info, please see the Cordova Contacts plugin docs
Usage
import {Contacts} from 'ionic-native';
Contacts.save({
displayName: "Mr. Ionitron"
}).then((contact) => {}, (err) => {})
See the save()
docs for a full list of fields.
Static Methods
create(options)
Create a new Contact object.
Param | Type | Details |
---|---|---|
options |
Object
|
Object whose properties the created Contact should have. |
Returns:
Contact
Returns the created contact
find(fields, options)
Search for contacts in the Contacts list.
Example: Contacts.find([‘*’], { filter: ‘Max’ }) // will search for a displayName of ‘Max’
Param | Type | Details |
---|---|---|
fields |
string[]
|
Contact fields to be used as a search qualifier. A zero-length contactFields parameter is invalid and results in ContactError.INVALID_ARGUMENT_ERROR. A contactFields value of "*" searches all contact fields. |
options |
Object
|
the options to query with: filter: The search string used to find navigator.contacts. (string) (Default: "") multiple: Determines if the find operation returns multiple navigator.contacts. (Boolean) (Default: false) desiredFields: Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. (DOMString[]) [Optional] hasPhoneNumber(Android only): Filters the search to only return contacts with a phone number informed. (Boolean) (Default: false) |
Returns: Returns a Promise that resolves with the search results (an array of Contact objects)
pickContact()
Select a single Contact.
Returns: Returns a Promise that resolves with the selected Contact