You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "zdravko (JIRA)" <ji...@apache.org> on 2014/04/23 10:13:21 UTC
[jira] [Commented] (CB-6429) Stored numbers in a contacts array not
be stored or displayed properly
[ https://issues.apache.org/jira/browse/CB-6429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13977964#comment-13977964 ]
zdravko commented on CB-6429:
-----------------------------
Yep options.filter with empty string does not work. It doesn't work with string less than 3 chars neither. E.g. "Bob" will do find contact displayName Bob but "Bo" won't.
I have used version 0.2.5 maybe its fixed in the latest.Haven't tried yet.
Please advise.
> Stored numbers in a contacts array not be stored or displayed properly
> ----------------------------------------------------------------------
>
> Key: CB-6429
> URL: https://issues.apache.org/jira/browse/CB-6429
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android, Plugin Contacts
> Reporter: Anthony Scuderi
> Priority: Minor
>
> I was running this on Ubuntu 12.04. This code below was taken from the apache cordova website ==> http://cordova.apache.org/docs/en/2.5.0/cordova_contacts_contacts.md.html .
> I did modify the line one line to <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
> Testing the contacts plugin on an android device. When I run this it should print out the phone numbers that are stored in the contacts array. Seems like that is not be stored properly. Not sure if this is a tools issue or more of a cordova problem.
> <!DOCTYPE html>
> <html>
> <head>
> <title>Contact Example</title>
> <script type="text/javascript" charset="utf-8" src="cordova.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 a new contact
> var contact = navigator.contacts.create();
> // store contact phone numbers in ContactField[]
> var phoneNumbers = [];
> phoneNumbers[0] = new ContactField('work', '212-555-1234', false);
> phoneNumbers[1] = new ContactField('mobile', '917-555-5432', true); // preferred number
> phoneNumbers[2] = new ContactField('home', '203-555-7890', false);
> contact.phoneNumbers = phoneNumbers;
> // save the contact
> contact.save();
> // search contacts, returning display name and phone numbers
> var options = new ContactFindOptions();
> options.filter="";
> filter = ["displayName","phoneNumbers"];
> navigator.contacts.find(filter, onSuccess, onError, options);
> }
> // onSuccess: Get a snapshot of the current contacts
> //
> function onSuccess(contacts) {
> for (var i=0; i<contacts.length; i++) {
> // display phone numbers
> for (var j=0; j<contacts[i].phoneNumbers.length; j++) {
> alert("Type: " + contacts[i].phoneNumbers[j].type + "\n" +
> "Value: " + contacts[i].phoneNumbers[j].value + "\n" +
> "Preferred: " + contacts[i].phoneNumbers[j].pref);
> }
> }
> };
> // onError: Failed to get the contacts
> //
> function onError(contactError) {
> alert('onError!');
> }
> </script>
> </head>
> <body>
> <h1>Example</h1>
> <p>Find Contacts</p>
> </body>
> </html>
--
This message was sent by Atlassian JIRA
(v6.2#6252)