From 5cffdbcd278b0839b5f1369092c606462ff3de75 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 22 Aug 2020 00:56:12 +0300 Subject: [PATCH] Prevent asking for notification permissions until used by an HuC-3 game --- Cocoa/AppDelegate.m | 4 +++- Cocoa/Document.m | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cocoa/AppDelegate.m b/Cocoa/AppDelegate.m index e54012f..133fab7 100644 --- a/Cocoa/AppDelegate.m +++ b/Cocoa/AppDelegate.m @@ -51,7 +51,9 @@ JOYHatsEmulateButtonsKey: @YES, }]; - [NSUserNotificationCenter defaultUserNotificationCenter].delegate = self; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBNotificationsUsed"]) { + [NSUserNotificationCenter defaultUserNotificationCenter].delegate = self; + } } - (IBAction)toggleDeveloperMode:(id)sender diff --git a/Cocoa/Document.m b/Cocoa/Document.m index ece8092..c7c1e35 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -404,6 +404,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) unsigned time_to_alarm = GB_time_to_alarm(&gb); if (time_to_alarm) { + [NSUserNotificationCenter defaultUserNotificationCenter].delegate = (id)[NSApp delegate]; NSUserNotification *notification = [[NSUserNotification alloc] init]; NSString *friendlyName = [[self.fileName lastPathComponent] stringByDeletingPathExtension]; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\([^)]+\\)|\\[[^\\]]+\\]" options:0 error:nil];