17

I have an app that has worked perfectly well with the CNContacts framework all the way up to IOS 12. I'm currently testing it with IOS 13 beta and its completely broken. I've checked the contacts permissions and deleted the app and re-allowed the permissions. This is the code I'm using to retrieve all contacts:

NSError* error;

CNContactStore *store = [[CNContactStore alloc]init];

[store containersMatchingPredicate:[CNContainer predicateForContainersWithIdentifiers: @[store.defaultContainerIdentifier]] error:&error];

NSArray *keysToFetch =@[CNContactGivenNameKey, CNContactEmailAddressesKey, CNContactNoteKey];

CNContactFetchRequest *request = [[CNContactFetchRequest alloc]initWithKeysToFetch:keysToFetch];

BOOL success = [store enumerateContactsWithFetchRequest:request error:&error usingBlock:^(CNContact * __nonnull contact, BOOL * __nonnull stop){

       NSLog(@"Contact Found: %@", contact.givenName);

}];

The contact store builds fine, and the error is nil. However when I then try to get the contacts via the fetch request I get success=NO and I receive the following error:

Error Domain=CNErrorDomain Code=102 "(null)" UserInfo={CNKeyPaths=(
    note
), CNInvalidRecords=(
    "<CNContactFetchRequest: 0x60000189aa00: predicate=(null), keysToFetch=(\n    givenName,\n    emailAddresses,\n    note\n), unifyResults=1, sortOrder=0>"

I've tried various tweaks but I cannot get this to work at all. I also can't find any documentation to say this has behaviour has been changed.

Has anyone else also tried this or found a work around?

Plasma
  • 2,622
  • 2
  • 20
  • 35
  • Looks to be related to this new entitlement: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_contacts_notes – Anya Shenanigans Aug 15 '19 at 11:24
  • @Petesh that looks like exactly what it is, I really wish they made the changes more obvious. Also If I can't get an entitlement accepted for my app all, I'll need to employ a work around, at huge inconvenience to my customers. If you post the above as an answer I will accept it as a solution. Thanks for the info. – Plasma Aug 15 '19 at 16:55
  • @Plasma have you been able to get approved for this entitlement? We requested approval weeks ago and have heard nothing from Apple. – haplo1384 Oct 01 '19 at 16:56
  • 1
    I applied for the entitlement, but was taking too long, so I redesigned my app so it doesn't need the entitlement, and managed to keep all the features. The update was accepted and I'm all sorted, not sure it will be as easy for others but I wish you luck. – Plasma Oct 01 '19 at 20:20

3 Answers3

26

In iOS 13, apple have added a new entitlement that is needed if you wish to access the notes for contacts. The entitlement is com.apple.developer.contacts.notes. You can request permission to use this entitlement for an app being put in the App Store.

The reason it was added is primarily for privacy reasons — the notes field can contain any information you might have on the contact; and a lot of times this information is significantly more sensitive than just the contact information.

As of 2019-08-15, this entitlement sits in the beta category, which means it may be subject to change before the release of iOS 13, and the name of the entitlement will probably stabilize in it’s presentation to the developer in Xcode.

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
  • 2
    have you been able to get approval for this entitlement? We requested permission using the link above weeks ago and we cannot get an answer from Apple. – haplo1384 Oct 01 '19 at 16:54
  • 2
    No, I've heard nothing from apple, and it's not visible in the provisioning UI on the website, or in XCode. It appears to be a 'dropped the ball' issue - I would suggest filing an issue about it. – Anya Shenanigans Oct 01 '19 at 17:27
  • 2
    I filed a developer issue and the response was apply for permission to use the profile, and I expect if you get approved it will appear in the provisioning profile for the app, but otherwise will be unusable. In the interim I just nixed getting the notes field as it was not needed for my use case – Anya Shenanigans Oct 08 '19 at 14:56
  • 1
    Thanks @Petesh, we finally got in contact with the internal review team and they said they expect our review to be complete this week. Their reason for the delay was the number of requests they received. – haplo1384 Oct 08 '19 at 18:20
  • 1
    Do enterprise apps need this request approved by Apple as well? I ask as the link says "Before you can submit an app with this entitlement to the App Store, you must first get permission to use the entitlement.". – Vaibhav Misra Oct 10 '19 at 02:01
  • @VaibhavMisra I don't know. I have no experience with special entitlements for enterprise apps. – Anya Shenanigans Oct 23 '19 at 10:37
  • 2
    Someone received answer for the request? – Michel Marqués Oct 29 '19 at 10:39
9

For me this seemed to be caused by the presence of CNContactNoteKey in the "keys to fetch". Removing it restores functionality.

I see you have CNContactNoteKey present, too.

I have flagged this to Apple as a bug.

Peter Johnson
  • 3,764
  • 1
  • 23
  • 27
  • 3
    Turns out its not a bug, see comment by @Petesh above and this link here .. https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_contacts_notes?language=objc – Plasma Aug 15 '19 at 16:52
  • Wouldn't the bug be: give me an error message that says which key was the offending key? – benc Jan 12 '21 at 03:59
3

The latest com.apple.developer.contacts.notes entitlement for iOS 13 is not updated in Xcode as well as in-app id configuration in Apple developer portal. Currently, we are blocked because of the same. Can someone please let us know how to proceed with this. If we add com.apple.developer.contacts.notes manually to an entitlement, it throws an error which says:

Provisioning profile "iOS Development Profile" doesn't include the com.apple.developer.contacts.notes entitlement.

Thanks,
Sanath

Iurii Tkachenko
  • 3,106
  • 29
  • 34
user948440
  • 31
  • 3