CB-11041: cordova-plugin-contacts readme must be updated to include instructions on removing phone number from a contact
This closes #119
diff --git a/README.md b/README.md
index b5debb6..4928343 100644
--- a/README.md
+++ b/README.md
@@ -354,6 +354,33 @@
// remove the contact from the device
contact.remove(onSuccess,onError);
+### Removing phone number(s) from a saved contact
+
+ // Example to create a contact with 3 phone numbers and then remove
+ // 2 phone numbers. This example is for illustrative purpose only
+ var myContact = navigator.contacts.create({"displayName": "Test User"});
+ var phoneNumbers = [];
+
+ phoneNumbers[0] = new ContactField('work', '768-555-1234', false);
+ phoneNumbers[1] = new ContactField('mobile', '999-555-5432', true); // preferred number
+ phoneNumbers[2] = new ContactField('home', '203-555-7890', false);
+
+ myContact.phoneNumbers = phoneNumbers;
+ myContact.save(function (contact_obj) {
+ var contactObjToModify = contact_obj.clone();
+ contact_obj.remove(function(){
+ // Note: Do NOT use delete operator to remove the phone numbers. It will break in android.
+ var phoneNumbers = [contactObjToModify.phoneNumbers[0]];
+ contactObjToModify.phoneNumbers = phoneNumbers;
+ contactObjToModify.save(function(c_obj){
+ console.log("All Done");
+ }, function(error){
+ console.log("Not able to save the cloned object: " + error);
+ });
+ }, function(contactError) {
+ console.log("Contact Remove Operation failed: " + contactError);
+ });
+ });
### Android 2.X Quirks