Contacts
buildfire.device.contacts
#
This feature allows the app to access and to get devices contacts.
note
This feature works only on devices; so it will return an error if it was triggered outside devices
#
Requirementsplugin.json
#
In plugin.json add Contacts
in your features array "features" : [{"name" : "Contacts"}]
#
MethodsshowDialog()
#
buildfire.device.contacts.showDialog(options, callback)
This function allows you to select one contact, where it shows the contacts in the device via native UI and you can select one of them. It may also ask the user for permission to access the device's contacts if it hasn't previously.
callback(err, data)
#
Callback function after selecting a contact
Name | Type | Description |
---|---|---|
err | string | Error string, null when operation is successful |
data | object | The selected contact |
data
#
Name | Type | Description |
---|---|---|
name | string | The name of the contact |
emails | [object] | Array of the contact's emails, example "emails": [{"value":<string>,"pref":<bool>,"id":<number>,"type":<string>} |
photos | [object] | Array of the contact's photos, example "photos": [{"value":<string>,"pref":<bool>,"type":<string> |
phoneNumbers | [object] | Array of the contact's phone numbers, example "phoneNumbers": [{"value":<string>,"pref":<bool>,"id":<number>,"type":<string>} |
note
pref
and type
in (emails
, photos
and phoneNumbers
) are widely supported but make sure to check nullability (or being undefined) for both of them
#
Example of the received datasearch()
#
buildfire.device.contacts.search(options, callback)
This function allows you to select multiple contacts, where you will get all the contacts (in a drawer) from the device and you can select from them. It may also ask the user for permission to access the device's contacts if it hasn't previously.
options
#
Name | Type | Required | Description | Default |
---|---|---|---|---|
header | string | no | Text or HTML to be rendered as the drawer's header | |
content | string | no | Text or HTML to be rendered in the drawer's body | |
drawerButtonText | string | no | Text of the button | 'Import' |
drawerButtonType | string | no | Type of the button (primary, success, info, danger, warning, default) | 'success' |
callback(err, data)
#
Callback function after selecting contacts
Name | Type | Description |
---|---|---|
err | string | Error string, null when operation is successful |
data | [object] | Array of the selected contacts |
data
#
Name | Type | Description |
---|---|---|
name | string | The name of the contact |
emails | [object] | Array of the contact's emails, example "emails": [{"value":<string>,"pref":<bool>,"id":<number>,"type":<string>} |
photos | [object] | Array of the contact's photos, example "photos": [{"value":<string>,"pref":<bool>,"type":<string> |
phoneNumbers | [object] | Array of the contact's phone numbers, example "phoneNumbers": [{"value":<string>,"pref":<bool>,"id":<number>,"type":<string>} |
note
pref
and type
in (emails
, photos
and phoneNumbers
) are widely supported but make sure to check nullability (or being undefined) for both of them