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

Commit d232175

Browse files
committed
Callback notifications after a short delay.
1 parent 2035224 commit d232175

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

PermissionScope/PermissionScope.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,18 +600,20 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void
600600
defaults.setBool(true, forKey: Constants.NSUserDefaultsKeys.requestedNotifications)
601601
defaults.synchronize()
602602

603-
dispatch_async(dispatch_get_main_queue()) {
603+
// callback after a short delay, otherwise notifications don't report proper auth
604+
dispatch_after(
605+
dispatch_time(DISPATCH_TIME_NOW,Int64(0.1 * Double(NSEC_PER_SEC))),
606+
dispatch_get_main_queue(), {
604607
self.getResultsForConfig { results in
605608
guard let notificationResult = results
606609
.first({ $0.type == .Notifications }) else { return }
607-
608610
if notificationResult.status == .Unknown {
609611
self.showDeniedAlert(notificationResult.type)
610612
} else {
611613
self.detectAndCallback()
612614
}
613615
}
614-
}
616+
})
615617
}
616618

617619
/**

0 commit comments

Comments
 (0)