Delay requests to show notifications

This commit is contained in:
Lior Halphon 2020-05-30 22:46:06 +03:00
parent c665fcb2ed
commit 83b959c126
1 changed files with 16 additions and 13 deletions

View File

@ -360,6 +360,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[[NSRunLoop mainRunLoop] addTimer:hex_timer forMode:NSDefaultRunLoopMode];
/* Clear pending alarms, don't play alarms while playing */
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBNotificationsUsed"]) {
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
for (NSUserNotification *notification in [center scheduledNotifications]) {
if ([notification.identifier isEqualToString:self.fileName]) {
@ -374,6 +375,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
break;
}
}
}
while (running) {
if (rewind) {
@ -412,7 +414,8 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
notification.identifier = self.fileName;
notification.deliveryDate = [NSDate dateWithTimeIntervalSinceNow:time_to_alarm];
notification.soundName = NSUserNotificationDefaultSoundName;
[center scheduleNotification:notification];
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:notification];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"GBNotificationsUsed"];
}
[_view setRumble:0];
stopping = false;