I tried everything but I won't get the cordova plugin for contacts working within my web browser.
I even copied the example of the cordova page http://ift.tt/2dzm5AM and uploaded it to my web server. If I open the page on my iPhone I don't get anything from my contacts.
What do I do wrong? Or is it, that the way I check this on my phone is false? Can a browser even pick contacts from my phone?
I spent a whole weekend to get this working on my phone, set up everything as mentioned in the web, even made some native pages which only should grab a contact - nothing! I'm stuck!
Can anybody help with an example that works fine in a web browser?
as mentioned, it can also be that I misunderstand the whole thing, but as read in the web, html 5.0 should be able to grab contacts. Navigator.contacts.create or navigator.contacts.find for example didn't work in any of the tests I did. Always got an error in js.
Thank you very much in advance.
Sven
<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// create
var contact = navigator.contacts.create();
contact.displayName = "Plumber";
contact.nickname = "Plumber"; //specify both to support all devices
var name = new [ContactName](../ContactName/contactname.html)();
name.givenName = "Jane";
name.familyName = "Doe";
contact.name = name;
// save
contact.save(onSaveSuccess,onSaveError);
// clone
var clone = contact.clone();
clone.name.givenName = "John";
console.log("Original contact name = " + contact.name.givenName);
console.log("Cloned contact name = " + clone.name.givenName);
// remove
contact.remove(onRemoveSuccess,onRemoveError);
}
// onSaveSuccess: Get a snapshot of the current contacts
//
function onSaveSuccess(contact) {
alert("Save Success");
}
// onSaveError: Failed to get the contacts
//
function onSaveError(contactError) {
alert("Error = " + [contactError](../parameters/contactError.html).code);
}
// onRemoveSuccess: Get a snapshot of the current contacts
//
function onRemoveSuccess(contacts) {
alert("Removal Success");
}
// onRemoveError: Failed to get the contacts
//
function onRemoveError(contactError) {
alert("Error = " + [contactError](../parameters/contactError.html).code);
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Find Contacts</p>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire