Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

This API is available on Firefox OS for privileged or certified applications only.

The MozContact interface is used to describe a single contact in the device's contact database.

The properties of the interface are similar to those defined in the vCard 4.0 specification, with the following exceptions:

  • The vCard N attribute is split into 5 properties: familyName, givenName, additionalName, honorificPrefix, honorificSuffix
  • The vCard FN attribute is renamed name
  • The vCard GENDER attribute is split in 2 properties: sex, genderIdentity

Constructor

Starting from Firefox OS 1.3, the mozContact constructor accepts contact data as a parameter. This replaces the init method that has been deprecated. See Using the Contact API for a code sample that is compatible with all Firefox OS versions.

// Firefox OS 1.0 to Firefox OS 1.2
var contact = new mozContact();

// Firefox OS 1.3+
var contact = new mozContact(data);

Properties

Note that most of the properties are arrays. While Firefox OS 1.0 to 1.2 is more forgiving, Firefox 1.3 has been made stricter concerning the types, and therefore it is very important to follow the type accurately to have a compatible application.

mozContact.id Read only
A unique id of the contact in the device's contact database.
mozContact.published Read only
A Date object giving the first time the contact was stored. This will eventually be converted to a long long timestamp, therefore to stay compatible over time, you should use var published = +contact.published to get and use a timestamp in your code.
mozContact.updated Read only
A Date object giving the last time the contact was updated. This will eventually be converted to a long long timestamp, therefore to stay compatible over time, you should use var updated = +contact.updated to get and use a timestamp in your code.
mozContact.name
An array of string representing the different general names of the contact. This property can be used for searches since Firefox OS v1.3.
mozContact.honorificPrefix
An array of string representing the different honorific prefixes of the contact.
mozContact.givenName
An array of string representing the different given names of the contact. This property can be used for searches.
mozContact.additionalName
An array of string representing any additional names of the contact.
mozContact.familyName
An array of string representing the different family names of the contact. This property can be used for searches.
mozContact.honorificSuffix
An array of string representing the different honorific suffixes of the contact.
mozContact.nickname
An array of string representing the different nicknames of the contact.
mozContact.email
An array of objects, each representing an e-mail with a few extra metadata. The email value can be used for searches.
mozContact.photo
An array of Blob, which store the photos for the contact.
mozContact.url
An array of objects, each representing a URL with a few extra metadata.
mozContact.category
An array of strings representing the different categories the contact is associated with. This property can be used for searches.
mozContact.adr
An array of objects, each representing an address.
mozContact.tel
An array of objects, each representing a phone number with a few extra metadata. The phone value can be used for searches, and has special matching criteria.
mozContact.org
An array of strings representing the different organizations the contact is associated with.
mozContact.jobTitle
An array of strings representing the different job titles of the contact.
mozContact.bday
A Date object representing the date of birth of the contact. This will eventually be converted to a long long timestamp, therefore to stay compatible over time, you should use var bday = +contact.bday to get and use a timestamp in your code.
mozContact.note
An array of strings representing notes about the contact.
mozContact.impp
An array of objects, each representing an Instant Messaging address with a few extra metadata.
mozContact.anniversary
A Date object representing the date of marriage anniversary of the contact. This will eventually be converted to a long long timestamp, therefore to stay compatible over time, you should use var anniversary = +contact.anniversary to get and use a timestamp in your code.
mozContact.sex
A string representing the sex of the contact.
mozContact.genderIdentity
A string representing the gender identity of the contact.
mozContact.key
A array of string representing the public encryption key associated with the contact.

Methods

mozContact.init()
Allows to initialize the contact object. This method has been deprecated in Firefox v1.3. See Using the Contact API for a code sample that is compatible with all Firefox OS versions.

Specifications

Specification Status Comment
Contacts Manager API
The definition of 'Contacts Manager API' in that specification.
Working Draft First Working Draft (unstable)
vCard Format Specification IETF RFC RFC 6350

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
basic support No support No support No support No support No support
Feature Android Chrome for Android Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
basic support No support No support 1.0.1[1] No support No support No support

[1] As the specification is unstable, the Gecko implementation is completely non-standard.

See also

Document Tags and Contributors

 Last updated by: chrisdavidmills,