facebook

navigator.contacts.find and IOS 6 : CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #336496 Reply

    Yann
    Member

    Hello,
    i would like display contacts list with cordova via
    navigator.contacts.find

    var options = new ContactFindOptions();
    options.filter=""; 
    options.multiple = true;
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, onSuccess, onError, options);

    when i build ios app, i have the message saying if i allow my app to access to my contacts, on yes click nothing happen.
    i take a look in privacy settings>Contact and i see my app with access allowed, however when i click on my button my contact list is not displayed.
    any idea?
    thanks
    Yann

    #336505 Reply

    Brandon
    Member

    Yann,

    I havent used it before, but I did notice the filter was set “” perhaps its not returning anything. Have you tried setting this to a known contact just to make sure?

    #336507 Reply

    Yann
    Member

    hello CincyPlanet
    I thought the function navigator.contacts.find calls a window like the camera
    but I just realized that the function sent me a list of contacts and I must build my list with it
    damned I Don’t Like Mondays 😉
    thanks
    Yann

    #336508 Reply

    Brandon
    Member

    Yeah, as far as I know you can’t use their contacts window for selections.

    #341128 Reply

    Kind of related to the same issue, I am not able to display the Contacts details, even though I reach the database and get into the onSuccess routine.

    Contacts.length is set to > zero indicating I have found multiple matching entries.

    Then I try to use the returned Contacts array via Contacts[0].name, Contacts[0].lastname, Contacts[0].phoneNumber etc and I get no data returned.

    What am I doing wrong ?

    TG

    #341167 Reply

    @tguneysu,

    Can you share your environment details?
    1) Mobione version, if it’s Mobione 2.5M-1 please specify Cordova version selected.
    2) Where you are testing the app? iOS, Android, Test Center, Web SIM?

    Q: In case you’re building an android app, did you check the Contacts & Accounts option in the Services & Permissions tab on build wizard?

    #341173 Reply

    OS: Win7 Home Premium SP1
    MOBI: 2.3.1 and 2.5 m1 (happens in both)
    2.5 m1 Settings: Apache Cordova 2.9
    iPhone 4/4S IOS: 6.13
    APP: DevContactTest.mobi and DevContactTest_custom.js attached
    IMG: I attached the iPhone screen shot after the Contacts access.

    Octavio,

    I am running the APP in the iPhone as I do not have a Contacts database on the PC.

    I have included a small demo program to show what is happening.

    I can access the Phonegap Device and Contacts modules OK.
    I display the Phone device details without a problem.
    I locate the contact that I am looking for, no problem. Contacts.length confirms it.

    But when I try to display the Contacts[0].name, it does not output the actual name.
    I tried it with various combos: displayname, knickname and none of them display.

    I have copied the Contacts routine as it is from the PhoneGap API site and use their syntax to display.

    It would be helpful if I could get the actual database fields displayed.

    Thanks, TG

    Attachments:
    You must be logged in to view attached files.
    #341185 Reply

    Hi tguneysu,

    Thanks for sharing those details. We’ll investigate asap and will let you know when I have more info.

    #341190 Reply

    Hi tguneysu,

    Thanks again for the sample project that was very useful to spot the problem, please try using one of next snippets:

    Contacts[0].name.formatted
    Contacts[0].displayName
    #341194 Reply

    Hi Octavio,

    Contacts[0].name.formatted worked and displays the First and Last Names.

    Contacts[0].displayName displays null.

    This is great progress as far as the name display goes. Do you know if the other fields in the contacts also will need modified field names for display or not ?

    If I get time, I will code some more fields into to test program to see what they do, and report.

    Unless you have further feedback on other fields, I will consider this closed.

    Thanks again,
    Turgut

    #341211 Reply

    Hi,

    >Contacts[0].displayName displays null.

    displayName: This property is not supported by iOS and will be returned as null unless there is no ContactName specified. If there is no ContactName, then composite name, nickame or “” is returned for displayName, respectively.

    See iOS quirks: http://docs.phonegap.com/en/2.2.0/cordova_contacts_contacts.md.html#Contacts

    >Do you know if the other fields in the contacts also will need modified field names for display or not ?
    Note that you were using the name property which type is ContactName, because of that, you were getting a unexpected string when you used it.

    You can use the properties of .name(ContactName) that retun a string:

    Properties

    formatted: The complete name of the contact. (DOMString)
    familyName: The contacts family name. (DOMString)
    givenName: The contacts given name. (DOMString)
    middleName: The contacts middle name. (DOMString)
    honorificPrefix: The contacts prefix (example Mr. or Dr.) (DOMString)
    honorificSuffix: The contacts suffix (example Esq.). (DOMString)

    Hope this make sense.

    #341229 Reply

    Octavio,

    I had a chance to test the program with various fields.
    I am including the TEST PROGRAM hoping that it will help someone else, like it did me.

    As it is, one enters a filter string into the top field, where it says enter contact name.
    Then when the green button is pressed, it will display the DEVICE parameters and access CONTACTS on the phone.
    If a matching record is found, it will display the number of matches, but it will only display the first one with [0] index.

    I tested the program on an iPHONE 4 with IOS6.13:
    MOBI2.3 – worked OK
    MOBI2.5 Cordoba 2.2 – worked OK
    MOBI2.5 Cordoba 2.9 – worked OK

    Thanks again for your help in clarifying how to access CONTACTS database fields

    Turgut

    Attachments:
    You must be logged in to view attached files.
    #341252 Reply

    Hi Turgut,

    You’re welcome. Glad to help. Thank you for sharing your test program, it will be very helpful for other users who wants to use this API.

Viewing 13 posts - 1 through 13 (of 13 total)
Reply To: navigator.contacts.find and IOS 6 : CLOSED

You must be logged in to post in the forum log in