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
9 Answers
-
For iOS,
recordId
is the property that holds the unique ID. For Android,id
is the unique ID. -
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
-
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 !
-
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….
-
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. -
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 :(
-
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 :(
-
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);
-
In android no unique ID is returned :-( Can someone confirm this?