[AltStore] Fixes duplicate alerts when refreshing in background

This commit is contained in:
Riley Testut
2019-07-31 14:34:04 -07:00
parent 4fb07176e3
commit e77b35f0db

View File

@@ -383,9 +383,15 @@ private extension AppDelegate
if delay > 0
{
DispatchQueue.global().asyncAfter(deadline: .now() + delay) {
// If app is still running at this point, we schedule another notification with same identifier.
// This prevents the currently scheduled notification from displaying, and starts another countdown timer.
scheduleFinishedRefreshingNotification()
UNUserNotificationCenter.current().getPendingNotificationRequests() { (requests) in
// If app is still running at this point, we schedule another notification with same identifier.
// This prevents the currently scheduled notification from displaying, and starts another countdown timer.
// First though, make sure there _is_ still a pending request, otherwise it's been cancelled
// and we should stop polling.
guard requests.contains(where: { $0.identifier == identifier }) else { return }
scheduleFinishedRefreshingNotification()
}
}
}
}