w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

Cannot save contact to phone

I have a button with this clickevent:

function onSuccess(contact) {
alert("Save Success");
};

function onError(contactError) {
alert("Error = " + contactError.code);
};

alert("1");
var myContact = navigator.contacts.create({"displayName": "Jane Doe"});
alert("2");
myContact.note = "This contact has a note.";
alert("3");
var name = new ContactName();
name.givenName = "Jane givenname";
name.familyName = "Doe familyname";
myContact.name = name;
alert("4");
contact.save(onSuccess,onError);
alert("5");

I have ALL android permissions checked in the app settings.

The app gives me the alert windows until alert("4"), but doesn't show 5 and doesn't show "save success" or "error". What am I doing wrong?

This is a basic case to add a contact, so I don't know what is wrong.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Cannot save contact to phone

Hi,

On what device are you testing?
What's the OS?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Cannot save contact to phone

Hi!

There is a typo. You have a variable "myContact", but then you use "contact" that is undefined.

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

Cannot save contact to phone

My apologies, now it is working.

Is there a way to check for these kind of syntax errors? Because now the code is very short, but what if I have a script of a couple of pages?

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

Cannot save contact to phone

Unfortunately not.
Just check errors in Console...

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

Cannot save contact to phone

Yes, in firefox, but for things like this (contact.save) , it is a native app, so I don't have a console to log errors I think?

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

Cannot save contact to phone

If your code is too big and you can't find error manually then you can download Eclipse/xCode project and debug it in Eclipse/xCode.

Harold Gottschalk
Posts: 0
Joined: Wed Mar 27, 2013 9:42 pm

Cannot save contact to phone

For Debugging on device.

You can use Weinre Phonegap build provides a cloud version it is a bit slow. I have also used Catalyst from trigger.io it works pretty good and is free to use. Appery.io could provide a similar service since it is all based on Weinre.

Return to “Issues”