osx - CNContact for Mac OS X 10.11 -


from os x 10.11 , ios 9.0 apple provided framework contacts:

https://developer.apple.com/library/prerelease/mac/documentation/contacts/reference/contacts_framework/index.html#//apple_ref/doc/uid/tp40015328

and access contacts mac, cannot anything, because app not have access contacts:

switch cncontactstore.authorizationstatusforentitytype(.contacts) {     case .authorized:         print("authorized")         nsuserdefaults.standarduserdefaults().setbool(true, forkey: "contactsallowed")     case .denied:         print("denied")         nsuserdefaults.standarduserdefaults().setbool(false, forkey: "contactsallowed")     case .notdetermined:         print("not determined")     case .restricted:         print("restricted")     } 

the app never prompts allow access contacts, neither can select in system preferences (it not show up).

has idea how acccess them on mac (on ios works well)?

any call instance of cncontactstore should trigger request. if not try

  1. reboot (actually helped me; granted access)
  2. turn on sandboxing
  3. resetprivacy settings "sudo tccutil reset addressbook"
  4. call on main thread

instance of cncontactstore call:

[[cncontactstore alloc] init]; 

privacy

users can grant or deny access contact data on per-application basis. call cncontactstore block application while user being asked grant or deny access. note user prompted first time access requested; subsequent cncontactstore calls use existing permissions. avoid having app’s ui main thread block access, can use either asynchronous method [cncontactstore requestaccessforentitytype:cnentitytypecontacts completionhandler:] or dispatch cncontactstore usage background thread.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -