This version of the documentation is outdated!
Click here for the latest released version.
contacts.create
返回一個新的連絡人物件。
var contact = navigator.contacts.create(properties);
說明
contacts.create
方法是同步的並返回一個新的 Contact
物件。
此方法不會保留連絡人物件在設備的連絡人資料庫中,您需要為其調用 Contact.save
方法。
支援的平臺
- Android 系統
- 黑莓手機 WebWorks (OS 5.0 和更高)
- iOS
- Windows Phone 7 和 8
快速的示例
var myContact = navigator.contacts.create({"displayName": "Test User"});
完整的示例
<!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() {
var myContact = navigator.contacts.create({"displayName": "Test User"});
myContact.note = "This contact has a note.";
console.log("The contact, " + myContact.displayName + ", note: " + myContact.note);
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Create Contact</p>
</body>
</html>