{"id":38500,"date":"2023-02-16T16:30:28","date_gmt":"2023-02-16T21:30:28","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=38500"},"modified":"2023-12-06T14:20:00","modified_gmt":"2023-12-06T19:20:00","slug":"adding-contacts-without-entitlements","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2023\/02\/16\/adding-contacts-without-entitlements\/","title":{"rendered":"Adding Contacts Without Entitlements"},"content":{"rendered":"<p><a href=\"http:\/\/www.observationalhazard.com\/2023\/02\/adding-contacts-on-apple-platforms.html\">David Kopec<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.observationalhazard.com\/2023\/02\/adding-contacts-on-apple-platforms.html\">\n<p>For one-off contact additions, there&rsquo;s a simpler way that requires none of that. The idea is basic: you create a contact, save it in <a href=\"https:\/\/en.wikipedia.org\/wiki\/VCard\">vCard format<\/a>, and then ask the operating system to open the vCard file in the Contacts app. When the Contacts app opens, it will ask the user if they really want to add the contact. This requires no entitlements (even if you&rsquo;re using the <code>note<\/code> field), no authorization, and even works in a sandboxed app.<\/p>\n<p>[&#8230;]<\/p>\n<p>It works, but you might say, what about that <code>note<\/code> field? If you add a <code>note<\/code> property to your <code>CNMutableContact<\/code> you will notice it is silently dropped when the contact is added to the address book. This has nothing to do with the <code>note<\/code> special entitlement. It turns out <code>CNContactVCardSerialization<\/code> does not have support for either images or the note field. You can easily add both of these back. <a href=\"https:\/\/stackoverflow.com\/a\/70172455\/281461\">A Stack Overflow post provides some code showing how to do so.<\/a><\/p>\n<p>[&#8230;]<\/p>\n<p>When working on a new version of my macOS app <a href=\"https:\/\/apps.apple.com\/us\/app\/restaurants\/id941109837?mt=12\">Restaurants<\/a>, I came across the <code>note<\/code> field entitlement requirement. I submitted a request to Apple using their online form to have access to the entitlement and a week later I was rejected for my request being too vague. Fair enough, it&rsquo;s their sandbox, and they have the right to reject me for being too vague. But waiting so long to get an answer was frustrating and adding contacts requires a lot of ceremony.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/09\/08\/apple-still-sitting-on-entitlement-requests\/\">Apple Still Sitting on Entitlement Requests<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>David Kopec: For one-off contact additions, there&rsquo;s a simpler way that requires none of that. The idea is basic: you create a contact, save it in vCard format, and then ask the operating system to open the vCard file in the Contacts app. When the Contacts app opens, it will ask the user if they [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2023-02-16T21:30:31Z","apple_news_api_id":"09c49e36-84b9-4322-81ea-e233ccb0fabf","apple_news_api_modified_at":"2023-12-06T19:20:03Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/ACcSeNoS5QyKB6uIzzLD6vw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,176,2518,31,2185,71,901],"class_list":["post-38500","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-contacts","tag-entitlements","tag-ios","tag-ios-16","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/38500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=38500"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/38500\/revisions"}],"predecessor-version":[{"id":38501,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/38500\/revisions\/38501"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=38500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=38500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=38500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}