ioscncontactcncontactstore

CNContact: Contact Identifier properly changes after saving a contact to device


I am facing a strange problem only in one iPhone 11 pro. When I tried to save a new contact, first I save that contact and get the contactId and then I save to my DB.

First log: 2020/10/15 20:22:42:181 EVENT: OTHER Add/Updated Contact with deviceId = 19C34E70-0C79-4A5D-B7BF-A31229A3A157:ABPerson

Doing the above steps I get contactId with :ABPerson suffix and I update in my DB. We are also observing CNContactStoreChangeNotification, to get a notification for changes. On receiving notification for the change, When we try to search same new contact we added, we are getting new contactId for the same contact and due to that, we assume that now contact added through the app is deleted and another contact is added.

2020/10/15 20:22:45:717 [DEVICE_COMPARE]: To Be Added = 7BD48335-F4FD-408B-9807-495F5B34417F
2020/10/15 20:22:45:717 [DEVICE_COMPARE]: To Be Delete = 19C34E70-0C79-4A5D-B7BF-A31229A3A157:ABPerson

on Notification


Solution

  • You mentioned only seeing this problem on one device- does that device use a different default address book to your other devices? (specifically a Google address book)

    I have observed that .identifier changes a few moments after you save to a Google address book, but remains constant when you save to an iCloud address book.