Cordova update contact


#1

Hi

I am trying to use the contacts plugin. It works fine when I create a contact, but if I try to update one with the save function using identical id, it creates a duplicate anyway. But I read that if there is the same id, it should update the contact?

Here is my code:

‘click #addContact’: function () {

firstname = “Bart”;
lastname = “Simpson”;
id = ‘20’ //for example

function onSuccess(contact) {
swal(“Good job!”, “Contact added!”, “success”)
};

function onError(contactError) {
sweetAlert(“Oops…”, “Something went wrong!”, “error”);
};

// create a new contact object
var contact = navigator.contacts.create();

// populate some fields
var name = new ContactName();

// create a new contact object
var contact = navigator.contacts.create();
contact.displayName = name;
contact.nickname = nickname; // specify both to support all devices
contact.id = id;

name.givenName = firstname;
name.familyName = lastname;
contact.name = name;

// save to device
contact.save(onSuccess,onError);

}

#2

up up up

Does anyone know this plugin? Thanks :smiley: