Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

contacts unique ids

Hi,

in the api docs, there is a method "getPersonByID" mentioned.
but i dont see any ID property in contacts.person
when i try to access a .id propery my app crashs :/

is there a way to identify persons by an id ? or how should this be done ?
i want the user to select some persons and save a list of those people.
should this be done via first/lastname as identifier ?

method in question:
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Contacts.getPersonByID-method.html

— asked September 19th 2010 by tom kom
  • contacts
  • getpersonbyid
  • person
1 Comment
  • Bump! I can't find an answer to this question anywhere… has anyone actually used the getPersonByID function before? Seems like an entirely useless function without being able to get a contact's id in the first place.

    — commented January 10th 2011 by Charlie Rosenbury

9 Answers

  • For iOS, recordId is the property that holds the unique ID. For Android, id is the unique ID.

    — answered October 5th 2011 by Tony Lukasavage
    permalink
    0 Comments
  • you can use contact.recordId to get the DB id.

    only tested on iphone 4.1 emulator using 1.6 sdk

    I had to go have a look in the sdk source to figure it out :S

    — answered March 16th 2011 by Scott Williams
    permalink
    0 Comments
  • Hi,
    Does anyone have an answer on this ? I have the exact same need.
    if there is a getPersonById function, I suppose there is a way to get the id before calling it.

    How did you solve your issue ?

    Many thanks !

    — answered November 9th 2010 by Guillaume Levy
    permalink
    0 Comments
  • I had this problem a couple months ago…
    It seems that the iPHONE Address Book is more developed for quite a while.
    ANDROID has only recently been supported, and not real good support yet anyway.
    I was trying to solve the exact same issue, and got no where. I gave up… and just used the contact picker which works consistently across both android and iPHONE.

    Titanium.Contacts.showContacts({

    selectedPerson: function(e) {
    Ti.API.info('— inside selectedPerson ———');
    var person = e.person;
    Ti.API.info('fullName: '+person.fullName);
    var fullName = person.fullName;
    lll.text = person.fullName;
    var pp = person.phone;
    Ti.API.info('—— creating an array of contacts for dislaytable——-');
    var phonenumbers = [];

    for (var label in pp) {                
        Ti.API.info('------  step 01 -------' + label);;
        var ppp = pp[label];
    
            for (var i=0; i<ppp.length;i++){
            var otherPhones = ppp[i];
            Ti.API.info(label + ": "+otherPhones);
            phonenumbers.push({title:label+ ' - '+ otherPhones, hasChild:true, ph:otherPhones, fullName:fullName});    
                }; //for i
    
        }; //for label
    

    Not what you wanted to see… but….

    — answered March 16th 2011 by vincent youmans
    permalink
    0 Comments
  • If your doing an dialing app… I predict you are going to run into another problem. I posted a message on the help que you may want to check out…

    http://developer.appcelerator.com/question/117335/pauses-in-android-phone-numbers

    a pause in iPHONE is a ','
    a pause in ANDROID is a 'p'
    or so it seems… I want feedback to confirm this.

    — answered March 16th 2011 by vincent youmans
    permalink
    0 Comments
  • Thanks!

    Managed to get the id using contact.recordId as mentioned but I'm always getting a null when i try to use getPersonById..

    Tried:

    • getPersonById(1);

    • getPersonById('1');

    with no success :(

    — answered March 20th 2011 by Adrian Lu
    permalink
    0 Comments
  • Thanks!

    Managed to get the id using contact.recordId as mentioned but I'm always getting a null when i try to use getPersonById..

    Tried:

    • getPersonById(1);

    • getPersonById('1');

    with no success :(

    — answered March 20th 2011 by Adrian Lu
    permalink
    0 Comments
  • This works for me like a charme

    Ti.Contacts.showContacts({
        animated:true,
        selectedPerson:function(e) {
            Ti.API.info(e.person.recordId);
        }
    });
    var personData = Ti.Contacts.getPersonByID(parseInt(entries[c].contact,10));
    name = personData.fullName;
    Ti.API.info(name);
    
    — answered May 26th 2011 by Sebastian Klaus
    permalink
    0 Comments
  • In android no unique ID is returned :-( Can someone confirm this?

    — answered August 16th 2011 by Danny Pham
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.