cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rkn...@apache.org
Subject cordova-plugin-contacts git commit: CB-11041: cordova-plugin-contacts readme must be updated to include instructions on removing phone number from a contact
Date Fri, 08 Apr 2016 18:20:28 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master 0d33af8e4 -> 5bcbb201f


CB-11041: cordova-plugin-contacts readme must be updated to include instructions on removing
phone number from a contact

 This closes #119


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/5bcbb201
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/5bcbb201
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/5bcbb201

Branch: refs/heads/master
Commit: 5bcbb201f8b293ea85b848d3868c28e163d35c1d
Parents: 0d33af8
Author: Sarangan Rajamanickam <sarajama@microsoft.com>
Authored: Thu Apr 7 16:48:21 2016 -0700
Committer: Richard Knoll <richard.b.knoll@gmail.com>
Committed: Fri Apr 8 11:12:05 2016 -0700

----------------------------------------------------------------------
 README.md | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/5bcbb201/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index b5debb6..4928343 100644
--- a/README.md
+++ b/README.md
@@ -354,6 +354,33 @@ for details.
     // 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
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message