我不知道你是否可以使用該解決方案爲Android以及但是設備無關的方法對於iPhone,您可以使用.chooseContact()
方法。
例子:
<a href="#" onclick="contactChooser()">Choose a contact</a>
function contactChooser(){
//The chooseContact method will open a new window with all you contacts
navigator.contacts.chooseContact(
//After picking a name you will receive the id of the chosen contact
function(id){
//In an options variable you can set some filter parameters
//In this example we will use the Id to receive the data of the chosen contact
var options = {
filter: ""+id
}
//In the fields variable we're going to set the fields we want to receive
//'*' = every data. More field values are explained
// here: http://bit.ly/T8YyuE
var fields = ['*'];
navigator.contacts.find(fields, onPickContactSuccess, onPickContactError, options);
}, null);
}
function onPickContactSuccess(contacts){
//contacts contains all data you've requested
var _name = contacts[0].name
alert('Last: '+_name.familyName+' First: '+_name.givenName);
}
剛一說明:這似乎是唯一的iOS無證功能。見https://groups.google.com/forum/?fromgroups#!topic/phonegap/JI42d5prb-I – Anthony 2013-05-23 22:41:46