diff --git a/CMakeLists.txt b/CMakeLists.txt index e287d3a09..c8e9fae2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,6 +173,7 @@ if (UNIX) find_library (lib_ApplicationServices ApplicationServices) find_library (lib_Foundation Foundation) find_library (lib_Carbon Carbon) + find_library (lib_UserNotifications UserNotifications) list (APPEND libs ${lib_ScreenSaver} @@ -180,6 +181,7 @@ if (UNIX) ${lib_ApplicationServices} ${lib_Foundation} ${lib_Carbon} + ${lib_UserNotifications} ) else() # not-apple diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index ddeaf4416..fa29e8674 100755 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -46,6 +46,11 @@ #include #include #include +#include +#include +#include +#include +#include // This isn't in any Apple SDK that I know of as of yet. enum { @@ -919,7 +924,24 @@ void OSXScreen::enter() { - bool secure = isSecureInput(); + // Configure the notification's payload. + UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init]; + content.title = [NSString localizedUserNotificationStringForKey:@"Hello!" arguments:nil]; + content.body = [NSString localizedUserNotificationStringForKey:@"Hello_message_body" + arguments:nil]; + content.sound = [UNNotificationSound defaultSound]; + + // Deliver the notification in five seconds. + UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger + triggerWithTimeInterval:5 repeats:NO]; + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"FiveSecond" + content:content trigger:trigger]; + + // Schedule the notification. + UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; + [center addNotificationRequest:request]; + + bool secure = isSecureInput(); showCursor();