This topic describes the JavaScript APIs of WVContacts. You can refer to this topic when you create HTML5 apps or Miniapps. The JavaScript APIs of WVContacts provide capabilities related to the address book.
WVContacts.askAuth
This API is available only in WindVane iOS.
Requests access to the address book.
Input parameters
No input parameters exist.
Callback parameters
Callback parameters are passed into the callback method. If the version of iOS used is earlier than iOS 6, you do not need to request access to the address book and no callback is invoked. If the version of iOS used is iOS 6 or later, the success
callback is always invoked.
[
int
]isAuthed: indicates whether the app can access the address book. Valid values:0
and1
.
window.WindVane.call('WVContacts', 'askAuth', {}, function(e) {
alert(JSON.stringify(e));
});
WVContacts.authStatus
Obtains the current access state for the address book.
Input parameters
No input parameters exist.
Callback parameters
Callback parameters are passed into the callback method. This API always invokes the success
callback.
[
boolean
]isAuthed: indicates whether the app can access the address book. Valid values:0
and1
.[
int
]status: the specific access state. This parameter is available only inWindVane iOS
. Valid values:0
: Not Determined.1
: Restricted.2
: Denied.3
: Authorized.
window.WindVane.call('WVContacts', 'authStatus', {}, function(e) {
alert(JSON.stringify(e));
});
WVContacts.choose
Displays the contacts in the address book. After the user selects a contact, the name and phone number of the contact are returned to the related HTML5 page.
Input parameters
No input parameters exist.
Callback parameters
Callback parameters are passed into the callback method. If the user selects a contact, the success
callback is invoked. Otherwise, the failure
callback is invoked.
[
string
]name: the name of the contact that is selected.[
string
]phone: the phone number of the contact that is selected.
window.WindVane.call('WVContacts', 'choose', {}, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e))
});
WVContacts.find
Searches for a contact in the address book based on the specified name and phone number.
Input parameters
[
object
]filter: the contact filter. The filter contains the following properties:[
string
]name: the name of the queried contact.[
string
]phone: the phone number of the queried contact.
If both phone
and name
are configured, the contact that meets both filter conditions is returned. If a contact has multiple phone numbers, multiple records are displayed in the result list.
In iOS, any contact whose name contains the value of the
name
property or whose phone number contains the value of the phone property is returned.
Callback parameters
Callback parameters are passed into the callback method. This API always invokes the success
callback.
[
array
]contacts: the list of contacts that meet the filter conditions. Each item in the array contains the following properties:[
string
]name: the name of the contact that meets the filter conditions.[
string
]phone: the phone number of the contact that meets the filter conditions.
var params = {
// The contact filter.
filter: {
// Search for a contact with a specified name.
name: 'Jack',
// Search for a contact with a specified phone number.
phone: '123456'
}
}
window.WindVane.call('WVContacts', 'find', params, function(e) {
alert(JSON.stringify(e));
});
WVContacts.addPhoneContact
This API is available only in WindVane Android 1.0.3.4 or later.
Adds a contact.
Input parameters
[
string
]lastName: the last name of the contact.[
string
]firstName: the first name of the contact.[
string
]middleName: the middle name of the contact. This parameter is optional.[
string
]nickName: the nickname of the contact. This parameter is optional.[
string
]remark: the remarks. This parameter is optional.[
string
]mobilePhoneNumber: the phone number of the contact. This parameter is optional.[
string
]hostNumber: the business phone number or home phone number of the contact. This parameter is optional.[
string
]address: the address of the contact. This parameter is optional.[
string
]email: the email of the contact. This parameter is optional.[
string
]organization: the organization of the contact. This parameter is optional.[
string
]title: the job title of the contact. This parameter is optional.[
string
]photoPath: the local path of the profile picture. This parameter is optional.
Callback parameters
Parameters for the success callback:
No callback parameters exist.
Parameters for the failure callback:
[
string
]msg: the error message.
var params = {
lastName: 'xxx',
firstName: 'xxx',
middleName:'xxx',
nickName: 'xxx',
remark: 'xxx',
mobilePhoneNumber: '+86 12345',
hostNumber: '12345',
address: 'Beijing Chaoyang',
email: 'xxx@xxx.com',
organization: 'xxx',
title: 'xxx',
photoPath: '/storage/emulated/0/DCIM/Camera/xxx.jpg
}
window.WindVane.call('WVContacts', 'addPhoneContact', {}, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e))
});