Search code examples
iosxamarin.iosabaddressbook

Using ABAddressBook.GetPerson to retrieve the ABPerson returned by ABPeoplePickerNavigationController


I am using ABPeoplePickerNavigationController to allow the user to select an ABPerson from their address book. I import some data from that contact.

I would like to update a field in that ABPerson to indicate that I've already imported data from that ABPerson (I'm currently saving this in the Note field - is there any better way?)

But the object I get back from the SelectPerson event (ABPeoplePickerSelectPersonEventArgs.Person) is "detached" from the address book.

What I was hoping to do is something like:

        var book = new ABAddressBook();
        var p = book.GetPerson(e.Person.GetProperty(ABPersonProperty.ID));
        p.Note = "foo";
        book.Save();

But I can't find an appropriate property.

I read somewhere that there is a kABUIDProperty and was hoping that this is the int that GetPerson wants, but I can't find it on ABPerson.

Is there a way to do this?


Solution

  • This works fine for me:

        var book = new ABAddressBook();
        var p = book.GetPerson(e.Person.Id);
        p.Note = "TEST";
        book.Save();