Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Commit

Permalink
Callback notifications after a short delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoneill committed Jan 20, 2016
1 parent 2035224 commit d232175
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions PermissionScope/PermissionScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -600,18 +600,20 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void
defaults.setBool(true, forKey: Constants.NSUserDefaultsKeys.requestedNotifications)
defaults.synchronize()

dispatch_async(dispatch_get_main_queue()) {
// callback after a short delay, otherwise notifications don't report proper auth
dispatch_after(
dispatch_time(DISPATCH_TIME_NOW,Int64(0.1 * Double(NSEC_PER_SEC))),
dispatch_get_main_queue(), {
self.getResultsForConfig { results in
guard let notificationResult = results
.first({ $0.type == .Notifications }) else { return }

if notificationResult.status == .Unknown {
self.showDeniedAlert(notificationResult.type)
} else {
self.detectAndCallback()
}
}
}
})
}

/**
Expand Down

0 comments on commit d232175

Please sign in to comment.