What is the right way to communicate with ABPerson?

Many of my applications need to associate some data with a contact in the address book. What I used was to save the ABPerson record identifier and use this identifier to retrieve information each time the application starts. However, more and more, I find that this approach is incorrect, because many times the user will use a service such as mobileme, where the address book is wiped and reviewed. This changes the record identifier and all associations are lost. The user will have to go through each and re-link them.

Which is better for storing a reliable pointer to address book entries?

+4
source share
3 answers

You must save three values: record identifier, first name and last name.

1) In case the record identifier has not changed, you are golden - just use this to find the record you need.

2) If ABAddressBookGetPersonWithRecordID() does not find the record for your saved record identifier (it returns NULL), you will need to search for the personโ€™s records to match based on name and surname. You can opt out of using ABAddressBookCopyPeopleWithName() potentially or write your own location code if you already have an array with all the faces in memory. Finding a new record is up to you. To find a new record, you can update the data store with a new record identifier.

Ultimately, you end up saving the record ID so you can use it directly if it doesn't change (if you're lucky), and also save some keys from the address book entry that are unlikely to be changed. The name of the person or organization associated with the address book entry is likely to change. Of course, you should consider the case when you cannot find a record with a stored record identifier or by searching for a name. This may trivially mean that the record has been deleted, or it may mean that the record has been renamed. You must handle this case, whichever way you choose, is best for your specific application.

+5
source

I know that this was last year, however I thought that I could suggest a method that I use. The first time I ask the user to select a contact (to associate some personal data of my application with him), I then capture the record, create my own internal record identifier (application name initials and ordinal number usually) change the contact by adding a new name ABRelatedName ( type "pref" name "Other") of my own internal record identifier. This is similar to .vcf

 item3.X-ABRELATEDNAMES;type=pref:BZA101 item3.X-ABLabel:_$!<Other>!$_ 

This way, I can just refer to this post id when I add more user data, such as the last time the user of the application contacted them, etc. It seems to work for me.

Hope this helps someone.

+2
source

If the address book is really completely wiped and rebooted, and the only part that does not change is the display name, and saving the display name as the link seems to be the only option.

0
source

All Articles