Ca n'est past la dernière version de la documentation.
Cliquez ici pour voire la dernière version de la documentation.
ContactFindOptions
Contient des propriétés qui peuvent être utilisées pour filtrer les résultats d'une opération [contacts.find](../contacts.find.html)
.
Propriétés
filtre : la chaîne de recherche utilisée pour trouver des contacts. (DOMString) (Par défaut :
""
)multiples : détermine si l'opération find retourne plusieurs contacts. (Booléen) (Par défaut :
false
)
Plates-formes prises en charge
- Android
- BlackBerry WebWorks (OS 5.0 et plus)
- iOS
- Windows Phone 7 et 8
- Windows 8
Petit exemple
// success callback
function onSuccess(contacts) {
for (var i=0; i<contacts.length; i++) {
alert(contacts[i].displayName);
}
};
// error callback
function onError(contactError) {
alert('onError!');
};
// specify contact search criteria
var options = new ContactFindOptions();
options.filter=""; // empty search string returns all contacts
options.multiple=true; // return multiple results
filter = ["displayName"]; // return contact.displayName field
// find contacts
navigator.contacts.find(filter, onSuccess, onError, options);
Exemple complet
<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
// specify contact search criteria
var options = new ContactFindOptions();
options.filter = ""; // empty search string returns all contacts
options.multiple = true; // return multiple results
filter = ["displayName"]; // return contact.displayName field
// find contacts
navigator.contacts.find(filter, onSuccess, onError, options);
}
// onSuccess: Get a snapshot of the current contacts
//
function onSuccess(contacts) {
for (var i=0; i<contacts.length; i++) {
alert(contacts[i].displayName);
}
};
// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Find Contacts</p>
</body>
</html>