From 61ec8df418a2c314cf0e4025d716253830748186 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Wed, 13 Dec 2017 10:31:59 -0800 Subject: [PATCH] :wrench: More detailed macOS notification logging --- brightray/browser/mac/cocoa_notification.mm | 2 +- brightray/browser/mac/notification_center_delegate.mm | 7 ++++++- brightray/browser/mac/notification_presenter_mac.mm | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/brightray/browser/mac/cocoa_notification.mm b/brightray/browser/mac/cocoa_notification.mm index 0ca6512e04e2..df60f969d642 100644 --- a/brightray/browser/mac/cocoa_notification.mm +++ b/brightray/browser/mac/cocoa_notification.mm @@ -105,7 +105,7 @@ void CocoaNotification::NotificationButtonClicked() { if (delegate()) delegate()->NotificationAction(action_index_); - this->LogAction("clicked"); + this->LogAction("button clicked"); } void CocoaNotification::LogAction(const char* action) { diff --git a/brightray/browser/mac/notification_center_delegate.mm b/brightray/browser/mac/notification_center_delegate.mm index d8a8c9018347..c1a427e5f074 100644 --- a/brightray/browser/mac/notification_center_delegate.mm +++ b/brightray/browser/mac/notification_center_delegate.mm @@ -28,13 +28,18 @@ - (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification *)notif { auto notification = presenter_->GetNotification(notif); + + if (getenv("ELECTRON_DEBUG_NOTIFICATIONS")) { + NSLog(@"%s (%@)", "Cocoa notification activated", notif.identifier); + } + if (notification) { if (notif.activationType == NSUserNotificationActivationTypeReplied) { notification->NotificationReplied([notif.response.string UTF8String]); } else if (notif.activationType == NSUserNotificationActivationTypeActionButtonClicked) { notification->NotificationButtonClicked(); } else if (notif.activationType == NSUserNotificationActivationTypeContentsClicked) { - notification->NotificationClicked(); + notification->NotificationClicked(); } } } diff --git a/brightray/browser/mac/notification_presenter_mac.mm b/brightray/browser/mac/notification_presenter_mac.mm index b89030573462..ba403409b3f6 100644 --- a/brightray/browser/mac/notification_presenter_mac.mm +++ b/brightray/browser/mac/notification_presenter_mac.mm @@ -22,6 +22,11 @@ CocoaNotification* NotificationPresenterMac::GetNotification( isEqual:ns_notification.identifier]) return native_notification; } + + if (getenv("ELECTRON_DEBUG_NOTIFICATIONS")) { + NSLog(@"%s \"%@\"", "Could not find cocoa notification for", ns_notification.identifier); + } + return nullptr; }