ensure contact callback on proper thread

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 64bcc94589
commit dc75e592c1

@ -51,18 +51,21 @@ class SystemContactsFetcher: NSObject {
switch authorizationStatus { switch authorizationStatus {
case .notDetermined: case .notDetermined:
contactStore.requestAccess(for: .contacts, completionHandler: { (granted, error) in contactStore.requestAccess(for: .contacts) { (granted, error) in
if let error = error { if let error = error {
Logger.error("\(self.TAG) error fetching contacts: \(error)") Logger.error("\(self.TAG) error fetching contacts: \(error)")
assertionFailure() assertionFailure()
} }
if !granted { guard granted else {
Logger.info("\(self.TAG) declined contact access.") Logger.info("\(self.TAG) declined contact access.")
} else { return
}
DispatchQueue.main.async {
self.updateContacts() self.updateContacts()
} }
}) }
case .authorized: case .authorized:
self.updateContacts() self.updateContacts()
case .denied, .restricted: case .denied, .restricted:

Loading…
Cancel
Save