voltmx.contact Namespace
The voltmx.contact namspace, which is a part of the Phone API, provides the following API elements:
voltmx.contact Functions
The voltmx.contact namespace contains the following functions:
Note: The runtime permissions are applicable only in the iOS and Android platforms.
voltmx.contact.add
This API adds a contact to the address book of the mobile device.
Syntax
Input Parameters
contactDetails [Table] - Mandatory
A table that has the following key-value pairs.
Key | Description |
---|---|
firstname | specifies the first name of the contact |
lastname | specifies the last name of the contact |
phone | array of arrays containing Label and number |
> Note: The phone number can contain a + (for country code), - (hyphen) (to separate country code, STD code, and the number), and space ((to separate country code, STD code, and the number). No other characters are allowed within a phone number.For example, +919999999999, +91 99999 99999, or +91-99999-99999. | |
array of arrays containing Label and emailID | |
postal | array of arrays containing Label and address in a table with defined keys |
company | array of arrays containing Label followed by table with company name and title keys |
website | array of arrays containing url and type. type is not applicable for Windows platform. So any type value that may be provided for Windows is ignored. The possible types for the website key are as follows.Android: home, homepage, work, and othersiOS: home, homepage, work, ftp, blog, profile, and othersWindows: Not supported |
Example (For website key)
Note: firstname and phone fields are mandatory with at least one phone number in phone field
The following are the Labels for different fields in the table:
Keys in the Table | Possible Labels |
---|---|
phone | •Mobile •Home •Work •Other |
•Home •Work •Other | |
postal | •Home •Work •Other |
company | •Work •Other |
Example
Return Values
The following are the return values for this API:
Return Value | Description |
---|---|
Reference [Table] | Table containing the information related to the newly created contact is returned. |
nil | If the contact was not created. |
Error Codes
If any of the field is not stored, the field is ignored. If no field is stored, an error is raised.
Implementation Details
The following are the implementation details:
- firstname and phone field with empty string or nil does not create a contact and the API call is ignored.
- Other fields with empty string or nil or invalid data type assignment are ignored.
- id field is read only property and must not be modified by the application.
API Usage
When you use this API with Android emulator that uses Android SDK 2.0 and above, you will be prompted to create an account to add contacts.
Creating an account (Google/GMail) is a mandate to add contacts. This is an Android platform limitation.
Ensure that the following permissions are set for Android:
- READ_CONTACTS
- WRITE_CONTACTS
- GET_ACCOUNTS.
You can set these permissions for Android under Manifest Properties in Project Properties -> Native App -> Android. For more information about Android Manifest permissions, see Volt MX IrisUser Guide.
Platform Availability
- iOS
- Android
- Windows
voltmx.contact.details
This API displays the details of a given contact and returns a new instance of the contact structure.
The API is introduced to improve the performance and for effective utilization of memory. In platforms like Android, contact information is stored in multiple database tables, one table contains the contact id, first name, and lastname, and the another table contains the entire contact details. The contacts application displays only firstname, lastname in the initial screen, and when the user selects a particular contact, the details are shown in next screen.
When you to accommodate the contact details in one call to contact.find API, the memory is not sufficient when the contacts are numerous. This results in an out of memory issue and results in performance issues in many applications.
Syntax
Input Parameters
Parameter | Description |
---|---|
ReferenceTable - Mandatory | Specifies the reference table returned by the contact.find API |
Example
Return Values
Return Value | Description |
---|---|
Reference [Table] | Table of the contacts retrieved. The reference table retrieved contains a field photorawbytes. This is a new property in the existing contact structure that should be populated with raw bytes, just like camera or gallery raw bytes. |
nil | If no contact is retrieved. |
Example of the reference table returned:
Platform Availability
Available on all platforms except SPA, Desktop Web, Mobile Web.
voltmx.contact.find
This API parses through the address book of the mobile device and looks for contacts that match the input string.
Syntax
Input Parameters
Parameter | Description |
---|---|
firstName [String] - Mandatory | A string that represents the firstname of the contact. |
needdetails [Boolean] - Optional | When the needdetails parameter is not passed, the default value is true. When needdetails is set to true, this API returns the complete details of the contact. If needdetails is false, contact.find returns a list of contacts with a new field called displayname in the existing contact structure. All other fields of contact structure are not populated. displayname is a combination of firstname, middlename, and lastname. |
filterKeys [Array of strings] - Optional | You can use the filterKeys parameter to filter your search by passing any of the available keys of this parameter. If filterKeys is specified and needDetails is false, only the display name is returned. The available filter keys are as follows: “firstname”, “lastname”, “phone”, “postal”, “email”, “company”, “photorawbytes”, “displayname”, and “id”. The following platform-specific keys are available for the filterKeys parameter: For Windows and Android: “middlename” For Windows: “nickname” and “title” |
Example
Return Values
Return Value | Description |
---|---|
Reference [Object] | Table containing the list of all the contacts that contain the input string |
nil | If there is no contact with the specified first name |
Implementation Details
This API searches and matches only the contacts that have the firstname as the specified input string.
Platform Availability
Available on all platforms except SPA, Desktop Web, Mobile Web.
voltmx.contact.remove
This API deletes the contact (s) that was returned by the contact.find operation.
Syntax
Input Parameters
Parameter | Description |
---|---|
ReferenceTable - Mandatory | Specifies the reference table returned by the contact.find API |
Example
Return Values
Return Value | Description |
---|---|
Reference [Table] | Table of the contacts that is deleted |
nil | If there is no contact with the specified first name |
Platform Availability
Available on all platforms except SPA, Desktop Web, Mobile Web.