diff --git a/v3/examples/notifications/main.go b/v3/examples/notifications/main.go new file mode 100644 index 000000000..2bf9735fd --- /dev/null +++ b/v3/examples/notifications/main.go @@ -0,0 +1,131 @@ +package main + +import ( + _ "embed" + "fmt" + "log" + "time" + + "github.com/wailsapp/wails/v3/pkg/application" + "github.com/wailsapp/wails/v3/pkg/events" +) + +func main() { + app := application.New(application.Options{ + Name: "Notifications Demo", + Description: "A test of macOS notifications", + Assets: application.AlphaAssets, + }) + + app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ + Width: 500, + Height: 800, + }) + + app.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(event *application.ApplicationEvent) { + // Request pemission to send notifications + granted, err := application.RequestUserNotificationAuthorization() + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + + if granted { + // Send notification with no actions + err = application.SendNotification("some-uuid", "Title", "", "body!") + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + + err = application.RegisterNotificationCategory(application.NotificationCategory{ + ID: "MESSAGE_CATEGORY", + Actions: []application.NotificationAction{ + {ID: "VIEW_ACTION", Title: "View"}, + {ID: "MARK_READ_ACTION", Title: "Mark as Read"}, + {ID: "DELETE_ACTION", Title: "Delete", Destructive: true}, + }, + HasReplyField: true, + ReplyPlaceholder: "Type your reply...", + ReplyButtonTitle: "Reply", + }) + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + + err = application.SendNotificationWithActions(application.NotificationOptions{ + ID: "some-other-uuid", + Title: "New Message", + Subtitle: "From: Jane Doe", + Body: "Is it raining today where you are?", + CategoryID: "MESSAGE_CATEGORY", + Data: map[string]interface{}{ + "messageId": "msg-123", + "senderId": "user-123", + "timestamp": time.Now().Unix(), + }, + }) + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + } + }) + + app.OnApplicationEvent(events.Mac.DidReceiveNotificationResponse, func(event *application.ApplicationEvent) { + data := event.Context().GetData() + + // Parse data received + if data != nil { + if identifier, ok := data["identifier"].(string); ok { + fmt.Printf("Notification identifier: %s\n", identifier) + } + + if actionIdentifier, ok := data["actionIdentifier"].(string); ok { + fmt.Printf("Action Identifier: %s\n", actionIdentifier) + } + + if userText, ok := data["userText"].(string); ok { + fmt.Printf("User replied: %s\n", userText) + } + + if userInfo, ok := data["userInfo"].(map[string]interface{}); ok { + fmt.Printf("Custom data: %+v\n", userInfo) + } + + // Send notification to JS + app.EmitEvent("notification", data) + } + }) + + go func() { + time.Sleep(time.Second * 5) + // Sometime later check if you are still authorized + granted, err := application.CheckNotificationAuthorization() + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + println(granted) + + // Sometime later remove delivered notification by identifier + err = application.RemoveDeliveredNotification("some-uuid") + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + }() + + go func() { + time.Sleep(time.Second * 10) + // Sometime later remove all pending and delivered notifications + err := application.RemoveAllPendingNotifications() + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + err = application.RemoveAllDeliveredNotifications() + if err != nil { + log.Default().Printf("WARNING: %s\n", err) + } + }() + + err := app.Run() + if err != nil { + log.Fatal(err) + } +} diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/package.json b/v3/internal/runtime/desktop/@wailsio/runtime/package.json index 4c3544130..7412db923 100644 --- a/v3/internal/runtime/desktop/@wailsio/runtime/package.json +++ b/v3/internal/runtime/desktop/@wailsio/runtime/package.json @@ -1,7 +1,7 @@ { "name": "@wailsio/runtime", "type": "module", - "version": "3.0.0-alpha.56", + "version": "3.0.0-alpha.57", "description": "Wails Runtime", "types": "types/index.d.ts", "exports": { diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js index 9c7feed7c..f56a77cb6 100644 --- a/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js +++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js @@ -69,6 +69,7 @@ export const EventTypes = { ApplicationWillTerminate: "mac:ApplicationWillTerminate", ApplicationWillUnhide: "mac:ApplicationWillUnhide", ApplicationWillUpdate: "mac:ApplicationWillUpdate", + DidReceiveNotificationResponse: "mac:DidReceiveNotificationResponse", MenuDidAddItem: "mac:MenuDidAddItem", MenuDidBeginTracking: "mac:MenuDidBeginTracking", MenuDidClose: "mac:MenuDidClose", diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/types/event_types.d.ts b/v3/internal/runtime/desktop/@wailsio/runtime/types/event_types.d.ts index e8742de59..5c2d40009 100644 --- a/v3/internal/runtime/desktop/@wailsio/runtime/types/event_types.d.ts +++ b/v3/internal/runtime/desktop/@wailsio/runtime/types/event_types.d.ts @@ -69,6 +69,7 @@ export declare const EventTypes: { ApplicationWillTerminate: string, ApplicationWillUnhide: string, ApplicationWillUpdate: string, + DidReceiveNotificationResponse: string, MenuDidAddItem: string, MenuDidBeginTracking: string, MenuDidClose: string, diff --git a/v3/pkg/application/application_darwin.go b/v3/pkg/application/application_darwin.go index 623e4a94c..ce205b029 100644 --- a/v3/pkg/application/application_darwin.go +++ b/v3/pkg/application/application_darwin.go @@ -228,6 +228,41 @@ func (m *macosApp) setApplicationMenu(menu *Menu) { C.setApplicationMenu(m.applicationMenu) } +// RequestNotificationPermission requests user permission for notifications +func (m *macosApp) RequestNotificationPermission() (bool, error) { + return RequestUserNotificationAuthorization() +} + +// CheckNotificationPermission checks current permission status +func (m *macosApp) CheckNotificationPermission() (bool, error) { + return CheckNotificationAuthorization() +} + +// SendNotification sends a simple notification +func (m *macosApp) SendNotification(identifier, title, subtitle, body string) error { + return SendNotification(identifier, title, subtitle, body) +} + +// SendNotificationWithActions sends a notification with custom actions +func (m *macosApp) SendNotificationWithActions(options NotificationOptions) error { + return SendNotificationWithActions(options) +} + +// RegisterNotificationCategory registers a notification category with actions +func (m *macosApp) RegisterNotificationCategory(category NotificationCategory) error { + return RegisterNotificationCategory(category) +} + +// RemoveAllPendingNotifications removes all pending notifications +func (m *macosApp) RemoveAllPendingNotifications() { + RemoveAllPendingNotifications() +} + +// RemovePendingNotification removes a specific pending notification +func (m *macosApp) RemovePendingNotification(identifier string) { + RemovePendingNotification(identifier) +} + func (m *macosApp) run() error { if m.parent.options.SingleInstance != nil { cUniqueID := C.CString(m.parent.options.SingleInstance.UniqueID) diff --git a/v3/pkg/application/context_application_event.go b/v3/pkg/application/context_application_event.go index 468634f22..50cf8b90d 100644 --- a/v3/pkg/application/context_application_event.go +++ b/v3/pkg/application/context_application_event.go @@ -52,7 +52,7 @@ func (c ApplicationEventContext) HasVisibleWindows() bool { return c.getBool("hasVisibleWindows") } -func (c ApplicationEventContext) setData(data map[string]any) { +func (c *ApplicationEventContext) setData(data map[string]any) { c.data = data } @@ -72,6 +72,10 @@ func (c ApplicationEventContext) Filename() string { return result } +func (c *ApplicationEventContext) GetData() map[string]any { + return c.data +} + func newApplicationEventContext() *ApplicationEventContext { return &ApplicationEventContext{ data: make(map[string]any), diff --git a/v3/pkg/application/notifications_darwin.go b/v3/pkg/application/notifications_darwin.go new file mode 100644 index 000000000..e04075238 --- /dev/null +++ b/v3/pkg/application/notifications_darwin.go @@ -0,0 +1,177 @@ +//go:build darwin + +package application + +/* +#cgo CFLAGS: -mmacosx-version-min=10.14 -x objective-c +#cgo LDFLAGS: -framework Cocoa -mmacosx-version-min=10.14 -framework UserNotifications +#import "notifications_darwin.h" +*/ +import "C" +import ( + "encoding/json" + "fmt" + "unsafe" +) + +// NotificationAction represents a button in a notification +type NotificationAction struct { + ID string `json:"id"` + Title string `json:"title"` + Destructive bool `json:"destructive,omitempty"` + AuthenticationRequired bool `json:"authenticationRequired,omitempty"` +} + +// NotificationCategory groups actions for notifications +type NotificationCategory struct { + ID string `json:"id"` + Actions []NotificationAction `json:"actions"` + HasReplyField bool `json:"hasReplyField,omitempty"` + ReplyPlaceholder string `json:"replyPlaceholder,omitempty"` + ReplyButtonTitle string `json:"replyButtonTitle,omitempty"` +} + +// NotificationOptions contains configuration for a notification +type NotificationOptions struct { + ID string `json:"id"` + Title string `json:"title"` + Subtitle string `json:"subtitle,omitempty"` + Body string `json:"body"` + CategoryID string `json:"categoryId,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` +} + +// Check if the app has a valid bundle identifier +func CheckBundleIdentifier() bool { + return bool(C.checkBundleIdentifier()) +} + +// RequestUserNotificationAuthorization requests permission for notifications. +func RequestUserNotificationAuthorization() (bool, error) { + if !CheckBundleIdentifier() { + return false, fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + result := C.requestUserNotificationAuthorization(nil) + return result == true, nil +} + +// CheckNotificationAuthorization checks current permission status +func CheckNotificationAuthorization() (bool, error) { + if !CheckBundleIdentifier() { + return false, fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + return bool(C.checkNotificationAuthorization()), nil +} + +// SendNotification sends a notification with the given identifier, title, subtitle, and body. +func SendNotification(identifier, title, subtitle, body string) error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + cIdentifier := C.CString(identifier) + cTitle := C.CString(title) + cSubtitle := C.CString(subtitle) + cBody := C.CString(body) + defer C.free(unsafe.Pointer(cIdentifier)) + defer C.free(unsafe.Pointer(cTitle)) + defer C.free(unsafe.Pointer(cSubtitle)) + defer C.free(unsafe.Pointer(cBody)) + + C.sendNotification(cIdentifier, cTitle, cSubtitle, cBody, nil) + return nil +} + +// SendNotificationWithActions sends a notification with the specified actions +func SendNotificationWithActions(options NotificationOptions) error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + cIdentifier := C.CString(options.ID) + cTitle := C.CString(options.Title) + cSubtitle := C.CString(options.Subtitle) + cBody := C.CString(options.Body) + cCategoryID := C.CString(options.CategoryID) + defer C.free(unsafe.Pointer(cIdentifier)) + defer C.free(unsafe.Pointer(cTitle)) + defer C.free(unsafe.Pointer(cSubtitle)) + defer C.free(unsafe.Pointer(cBody)) + defer C.free(unsafe.Pointer(cCategoryID)) + + var cActionsJSON *C.char + if options.Data != nil { + jsonData, err := json.Marshal(options.Data) + if err == nil { + cActionsJSON = C.CString(string(jsonData)) + defer C.free(unsafe.Pointer(cActionsJSON)) + } + } + + C.sendNotificationWithActions(cIdentifier, cTitle, cSubtitle, cBody, cCategoryID, cActionsJSON, nil) + return nil +} + +// RegisterNotificationCategory registers a category with actions and optional reply field +func RegisterNotificationCategory(category NotificationCategory) error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + cCategoryID := C.CString(category.ID) + defer C.free(unsafe.Pointer(cCategoryID)) + + actionsJSON, err := json.Marshal(category.Actions) + if err != nil { + return err + } + cActionsJSON := C.CString(string(actionsJSON)) + defer C.free(unsafe.Pointer(cActionsJSON)) + + var cReplyPlaceholder, cReplyButtonTitle *C.char + if category.HasReplyField { + cReplyPlaceholder = C.CString(category.ReplyPlaceholder) + cReplyButtonTitle = C.CString(category.ReplyButtonTitle) + defer C.free(unsafe.Pointer(cReplyPlaceholder)) + defer C.free(unsafe.Pointer(cReplyButtonTitle)) + } + + C.registerNotificationCategory(cCategoryID, cActionsJSON, C.bool(category.HasReplyField), + cReplyPlaceholder, cReplyButtonTitle) + return nil +} + +// RemoveAllPendingNotifications removes all pending notifications +func RemoveAllPendingNotifications() error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + C.removeAllPendingNotifications() + return nil +} + +// RemovePendingNotification removes a specific pending notification +func RemovePendingNotification(identifier string) error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + cIdentifier := C.CString(identifier) + defer C.free(unsafe.Pointer(cIdentifier)) + C.removePendingNotification(cIdentifier) + return nil +} + +func RemoveAllDeliveredNotifications() error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + C.removeAllDeliveredNotifications() + return nil +} + +func RemoveDeliveredNotification(identifier string) error { + if !CheckBundleIdentifier() { + return fmt.Errorf("Notifications require a bundled application with a unique bundle identifier") + } + cIdentifier := C.CString(identifier) + defer C.free(unsafe.Pointer(cIdentifier)) + C.removeDeliveredNotification(cIdentifier) + return nil +} diff --git a/v3/pkg/application/notifications_darwin.h b/v3/pkg/application/notifications_darwin.h new file mode 100644 index 000000000..4014b9a1c --- /dev/null +++ b/v3/pkg/application/notifications_darwin.h @@ -0,0 +1,31 @@ +//go:build darwin + +#ifndef NOTIFICATIONS_DARWIN_H +#define NOTIFICATIONS_DARWIN_H + +#import + +#ifdef __cplusplus +extern "C" { +#endif + +bool checkBundleIdentifier(void); +bool requestUserNotificationAuthorization(void *completion); +bool checkNotificationAuthorization(void); +void sendNotification(const char *identifier, const char *title, const char *subtitle, const char *body, void *completion); + +// New advanced notification functions +void sendNotificationWithActions(const char *identifier, const char *title, const char *subtitle, + const char *body, const char *categoryId, const char *actions_json, void *completion); +void registerNotificationCategory(const char *categoryId, const char *actions_json, bool hasReplyField, + const char *replyPlaceholder, const char *replyButtonTitle); +void removeAllPendingNotifications(void); +void removePendingNotification(const char *identifier); +void removeAllDeliveredNotifications(void); +void removeDeliveredNotification(const char *identifier); + +#ifdef __cplusplus +} +#endif + +#endif /* NOTIFICATIONS_DARWIN_H */ \ No newline at end of file diff --git a/v3/pkg/application/notifications_darwin.m b/v3/pkg/application/notifications_darwin.m new file mode 100644 index 000000000..31152e13e --- /dev/null +++ b/v3/pkg/application/notifications_darwin.m @@ -0,0 +1,278 @@ +#import "notifications_darwin.h" +#import +#import +#import "../events/events_darwin.h" + +extern bool hasListeners(unsigned int); +extern void processApplicationEvent(unsigned int, void* data); + +@interface NotificationsDelegate : NSObject +@end + +@implementation NotificationsDelegate + +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { + UNNotificationPresentationOptions options = UNNotificationPresentationOptionList | + UNNotificationPresentationOptionBanner | + UNNotificationPresentationOptionSound; + completionHandler(options); +} + +- (void)userNotificationCenter:(UNUserNotificationCenter *)center +didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void (^)(void))completionHandler { + + NSMutableDictionary *payload = [NSMutableDictionary dictionary]; + + [payload setObject:response.notification.request.identifier forKey:@"identifier"]; + [payload setObject:response.actionIdentifier forKey:@"actionIdentifier"]; + [payload setObject:response.notification.request.content.title ?: @"" forKey:@"title"]; + [payload setObject:response.notification.request.content.body ?: @"" forKey:@"body"]; + + if (response.notification.request.content.categoryIdentifier) { + [payload setObject:response.notification.request.content.categoryIdentifier forKey:@"categoryIdentifier"]; + } + + if (response.notification.request.content.userInfo) { + [payload setObject:response.notification.request.content.userInfo forKey:@"userInfo"]; + } + + if ([response isKindOfClass:[UNTextInputNotificationResponse class]]) { + UNTextInputNotificationResponse *textResponse = (UNTextInputNotificationResponse *)response; + [payload setObject:textResponse.userText forKey:@"userText"]; + } + + // Check if there are listeners for our notification response event + if (hasListeners(EventDidReceiveNotificationResponse)) { + processApplicationEvent(EventDidReceiveNotificationResponse, (__bridge void*)payload); + } + + completionHandler(); +} + +@end + +static NotificationsDelegate *delegateInstance = nil; + +static void ensureDelegateInitialized(void) { + if (!delegateInstance) { + delegateInstance = [[NotificationsDelegate alloc] init]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + center.delegate = delegateInstance; + } +} + +bool checkBundleIdentifier(void) { + NSBundle *main = [NSBundle mainBundle]; + if (main.bundleIdentifier == nil) { + NSLog(@"Error: Cannot use notifications in development mode.\n" + " Notifications require the app to be properly bundled with a bundle identifier.\n" + " To test notifications:\n" + " 1. Build and package your app using 'wails package'\n" + " 2. Sign the packaged .app\n" + " 3. Run the signed .app bundle"); + return false; + } + return true; +} + +bool requestUserNotificationAuthorization(void *completion) { + if (!checkBundleIdentifier()) { + return false; + } + + ensureDelegateInitialized(); + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; + + [center requestAuthorizationWithOptions:options completionHandler:^(BOOL granted, NSError * _Nullable error) { + if (completion != NULL) { + void (^callback)(NSError *, BOOL) = completion; + callback(error, granted); + } + }]; + return true; +} + +bool checkNotificationAuthorization(void) { + ensureDelegateInitialized(); + + __block BOOL isAuthorized = NO; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { + isAuthorized = (settings.authorizationStatus == UNAuthorizationStatusAuthorized); + dispatch_semaphore_signal(semaphore); + }]; + + // Wait for response with a timeout + dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC)); + return isAuthorized; +} + +void sendNotification(const char *identifier, const char *title, const char *subtitle, const char *body, void *completion) { + ensureDelegateInitialized(); + + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + NSString *nsTitle = [NSString stringWithUTF8String:title]; + NSString *nsSubtitle = [NSString stringWithUTF8String:subtitle]; + NSString *nsBody = [NSString stringWithUTF8String:body]; + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + + UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + content.title = nsTitle; + content.subtitle = nsSubtitle; + content.body = nsBody; + content.sound = [UNNotificationSound defaultSound]; + + UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO]; + + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:nsIdentifier content:content trigger:trigger]; + + [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { + if (completion != NULL) { + void (^callback)(NSError *) = completion; + callback(error); + } + }]; +} + +void sendNotificationWithActions(const char *identifier, const char *title, const char *subtitle, + const char *body, const char *categoryId, const char *actions_json, void *completion) { + ensureDelegateInitialized(); + + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + NSString *nsTitle = [NSString stringWithUTF8String:title]; + NSString *nsSubtitle = subtitle ? [NSString stringWithUTF8String:subtitle] : @""; + NSString *nsBody = [NSString stringWithUTF8String:body]; + NSString *nsCategoryId = [NSString stringWithUTF8String:categoryId]; + + NSMutableDictionary *customData = [NSMutableDictionary dictionary]; + if (actions_json) { + NSString *actionsJsonStr = [NSString stringWithUTF8String:actions_json]; + NSData *jsonData = [actionsJsonStr dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + NSDictionary *parsedData = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + if (!error && parsedData) { + [customData addEntriesFromDictionary:parsedData]; + } + } + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + + UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + content.title = nsTitle; + if (![nsSubtitle isEqualToString:@""]) { + content.subtitle = nsSubtitle; + } + content.body = nsBody; + content.sound = [UNNotificationSound defaultSound]; + content.categoryIdentifier = nsCategoryId; + + // Add custom data if available + if (customData.count > 0) { + content.userInfo = customData; + } + + UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO]; + + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:nsIdentifier content:content trigger:trigger]; + + [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { + if (completion != NULL) { + void (^callback)(NSError *) = completion; + callback(error); + } + }]; +} + +void registerNotificationCategory(const char *categoryId, const char *actions_json, bool hasReplyField, + const char *replyPlaceholder, const char *replyButtonTitle) { + ensureDelegateInitialized(); + + NSString *nsCategoryId = [NSString stringWithUTF8String:categoryId]; + NSString *actionsJsonStr = actions_json ? [NSString stringWithUTF8String:actions_json] : @"[]"; + + NSData *jsonData = [actionsJsonStr dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + NSArray *actionsArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + + if (error) { + NSLog(@"Error parsing notification actions JSON: %@", error); + return; + } + + NSMutableArray *actions = [NSMutableArray array]; + + for (NSDictionary *actionDict in actionsArray) { + NSString *actionId = actionDict[@"id"]; + NSString *actionTitle = actionDict[@"title"]; + BOOL destructive = [actionDict[@"destructive"] boolValue]; + BOOL authRequired = [actionDict[@"authenticationRequired"] boolValue]; + + if (actionId && actionTitle) { + UNNotificationActionOptions options = UNNotificationActionOptionNone; + if (destructive) options |= UNNotificationActionOptionDestructive; + if (authRequired) options |= UNNotificationActionOptionAuthenticationRequired; + + UNNotificationAction *action = [UNNotificationAction + actionWithIdentifier:actionId + title:actionTitle + options:options]; + [actions addObject:action]; + } + } + + if (hasReplyField && replyPlaceholder && replyButtonTitle) { + NSString *placeholder = [NSString stringWithUTF8String:replyPlaceholder]; + NSString *buttonTitle = [NSString stringWithUTF8String:replyButtonTitle]; + + UNTextInputNotificationAction *textAction = + [UNTextInputNotificationAction actionWithIdentifier:@"TEXT_REPLY" + title:buttonTitle + options:UNNotificationActionOptionNone + textInputButtonTitle:buttonTitle + textInputPlaceholder:placeholder]; + [actions addObject:textAction]; + } + + UNNotificationCategory *category = [UNNotificationCategory + categoryWithIdentifier:nsCategoryId + actions:actions + intentIdentifiers:@[] + options:UNNotificationCategoryOptionNone]; + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center getNotificationCategoriesWithCompletionHandler:^(NSSet *categories) { + NSMutableSet *updatedCategories = [NSMutableSet setWithSet:categories]; + [updatedCategories addObject:category]; + [center setNotificationCategories:updatedCategories]; + }]; +} + +void removeAllPendingNotifications(void) { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removeAllPendingNotificationRequests]; +} + +void removePendingNotification(const char *identifier) { + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removePendingNotificationRequestsWithIdentifiers:@[nsIdentifier]]; +} + +void removeAllDeliveredNotifications(void) { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removeAllDeliveredNotifications]; +} + +void removeDeliveredNotification(const char *identifier) { + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removeDeliveredNotificationsWithIdentifiers:@[nsIdentifier]]; +} \ No newline at end of file diff --git a/v3/pkg/events/events.go b/v3/pkg/events/events.go index 0bb4c850c..84f214cac 100644 --- a/v3/pkg/events/events.go +++ b/v3/pkg/events/events.go @@ -112,6 +112,7 @@ type macEvents struct { ApplicationWillTerminate ApplicationEventType ApplicationWillUnhide ApplicationEventType ApplicationWillUpdate ApplicationEventType + DidReceiveNotificationResponse ApplicationEventType MenuDidAddItem ApplicationEventType MenuDidBeginTracking ApplicationEventType MenuDidClose ApplicationEventType @@ -248,116 +249,117 @@ func newMacEvents() macEvents { ApplicationWillTerminate: 1075, ApplicationWillUnhide: 1076, ApplicationWillUpdate: 1077, - MenuDidAddItem: 1078, - MenuDidBeginTracking: 1079, - MenuDidClose: 1080, - MenuDidDisplayItem: 1081, - MenuDidEndTracking: 1082, - MenuDidHighlightItem: 1083, - MenuDidOpen: 1084, - MenuDidPopUp: 1085, - MenuDidRemoveItem: 1086, - MenuDidSendAction: 1087, - MenuDidSendActionToItem: 1088, - MenuDidUpdate: 1089, - MenuWillAddItem: 1090, - MenuWillBeginTracking: 1091, - MenuWillDisplayItem: 1092, - MenuWillEndTracking: 1093, - MenuWillHighlightItem: 1094, - MenuWillOpen: 1095, - MenuWillPopUp: 1096, - MenuWillRemoveItem: 1097, - MenuWillSendAction: 1098, - MenuWillSendActionToItem: 1099, - MenuWillUpdate: 1100, - WebViewDidCommitNavigation: 1101, - WebViewDidFinishNavigation: 1102, - WebViewDidReceiveServerRedirectForProvisionalNavigation: 1103, - WebViewDidStartProvisionalNavigation: 1104, - WindowDidBecomeKey: 1105, - WindowDidBecomeMain: 1106, - WindowDidBeginSheet: 1107, - WindowDidChangeAlpha: 1108, - WindowDidChangeBackingLocation: 1109, - WindowDidChangeBackingProperties: 1110, - WindowDidChangeCollectionBehavior: 1111, - WindowDidChangeEffectiveAppearance: 1112, - WindowDidChangeOcclusionState: 1113, - WindowDidChangeOrderingMode: 1114, - WindowDidChangeScreen: 1115, - WindowDidChangeScreenParameters: 1116, - WindowDidChangeScreenProfile: 1117, - WindowDidChangeScreenSpace: 1118, - WindowDidChangeScreenSpaceProperties: 1119, - WindowDidChangeSharingType: 1120, - WindowDidChangeSpace: 1121, - WindowDidChangeSpaceOrderingMode: 1122, - WindowDidChangeTitle: 1123, - WindowDidChangeToolbar: 1124, - WindowDidDeminiaturize: 1125, - WindowDidEndSheet: 1126, - WindowDidEnterFullScreen: 1127, - WindowDidEnterVersionBrowser: 1128, - WindowDidExitFullScreen: 1129, - WindowDidExitVersionBrowser: 1130, - WindowDidExpose: 1131, - WindowDidFocus: 1132, - WindowDidMiniaturize: 1133, - WindowDidMove: 1134, - WindowDidOrderOffScreen: 1135, - WindowDidOrderOnScreen: 1136, - WindowDidResignKey: 1137, - WindowDidResignMain: 1138, - WindowDidResize: 1139, - WindowDidUpdate: 1140, - WindowDidUpdateAlpha: 1141, - WindowDidUpdateCollectionBehavior: 1142, - WindowDidUpdateCollectionProperties: 1143, - WindowDidUpdateShadow: 1144, - WindowDidUpdateTitle: 1145, - WindowDidUpdateToolbar: 1146, - WindowDidZoom: 1147, - WindowFileDraggingEntered: 1148, - WindowFileDraggingExited: 1149, - WindowFileDraggingPerformed: 1150, - WindowHide: 1151, - WindowMaximise: 1152, - WindowUnMaximise: 1153, - WindowMinimise: 1154, - WindowUnMinimise: 1155, - WindowShouldClose: 1156, - WindowShow: 1157, - WindowWillBecomeKey: 1158, - WindowWillBecomeMain: 1159, - WindowWillBeginSheet: 1160, - WindowWillChangeOrderingMode: 1161, - WindowWillClose: 1162, - WindowWillDeminiaturize: 1163, - WindowWillEnterFullScreen: 1164, - WindowWillEnterVersionBrowser: 1165, - WindowWillExitFullScreen: 1166, - WindowWillExitVersionBrowser: 1167, - WindowWillFocus: 1168, - WindowWillMiniaturize: 1169, - WindowWillMove: 1170, - WindowWillOrderOffScreen: 1171, - WindowWillOrderOnScreen: 1172, - WindowWillResignMain: 1173, - WindowWillResize: 1174, - WindowWillUnfocus: 1175, - WindowWillUpdate: 1176, - WindowWillUpdateAlpha: 1177, - WindowWillUpdateCollectionBehavior: 1178, - WindowWillUpdateCollectionProperties: 1179, - WindowWillUpdateShadow: 1180, - WindowWillUpdateTitle: 1181, - WindowWillUpdateToolbar: 1182, - WindowWillUpdateVisibility: 1183, - WindowWillUseStandardFrame: 1184, - WindowZoomIn: 1185, - WindowZoomOut: 1186, - WindowZoomReset: 1187, + DidReceiveNotificationResponse: 1078, + MenuDidAddItem: 1079, + MenuDidBeginTracking: 1080, + MenuDidClose: 1081, + MenuDidDisplayItem: 1082, + MenuDidEndTracking: 1083, + MenuDidHighlightItem: 1084, + MenuDidOpen: 1085, + MenuDidPopUp: 1086, + MenuDidRemoveItem: 1087, + MenuDidSendAction: 1088, + MenuDidSendActionToItem: 1089, + MenuDidUpdate: 1090, + MenuWillAddItem: 1091, + MenuWillBeginTracking: 1092, + MenuWillDisplayItem: 1093, + MenuWillEndTracking: 1094, + MenuWillHighlightItem: 1095, + MenuWillOpen: 1096, + MenuWillPopUp: 1097, + MenuWillRemoveItem: 1098, + MenuWillSendAction: 1099, + MenuWillSendActionToItem: 1100, + MenuWillUpdate: 1101, + WebViewDidCommitNavigation: 1102, + WebViewDidFinishNavigation: 1103, + WebViewDidReceiveServerRedirectForProvisionalNavigation: 1104, + WebViewDidStartProvisionalNavigation: 1105, + WindowDidBecomeKey: 1106, + WindowDidBecomeMain: 1107, + WindowDidBeginSheet: 1108, + WindowDidChangeAlpha: 1109, + WindowDidChangeBackingLocation: 1110, + WindowDidChangeBackingProperties: 1111, + WindowDidChangeCollectionBehavior: 1112, + WindowDidChangeEffectiveAppearance: 1113, + WindowDidChangeOcclusionState: 1114, + WindowDidChangeOrderingMode: 1115, + WindowDidChangeScreen: 1116, + WindowDidChangeScreenParameters: 1117, + WindowDidChangeScreenProfile: 1118, + WindowDidChangeScreenSpace: 1119, + WindowDidChangeScreenSpaceProperties: 1120, + WindowDidChangeSharingType: 1121, + WindowDidChangeSpace: 1122, + WindowDidChangeSpaceOrderingMode: 1123, + WindowDidChangeTitle: 1124, + WindowDidChangeToolbar: 1125, + WindowDidDeminiaturize: 1126, + WindowDidEndSheet: 1127, + WindowDidEnterFullScreen: 1128, + WindowDidEnterVersionBrowser: 1129, + WindowDidExitFullScreen: 1130, + WindowDidExitVersionBrowser: 1131, + WindowDidExpose: 1132, + WindowDidFocus: 1133, + WindowDidMiniaturize: 1134, + WindowDidMove: 1135, + WindowDidOrderOffScreen: 1136, + WindowDidOrderOnScreen: 1137, + WindowDidResignKey: 1138, + WindowDidResignMain: 1139, + WindowDidResize: 1140, + WindowDidUpdate: 1141, + WindowDidUpdateAlpha: 1142, + WindowDidUpdateCollectionBehavior: 1143, + WindowDidUpdateCollectionProperties: 1144, + WindowDidUpdateShadow: 1145, + WindowDidUpdateTitle: 1146, + WindowDidUpdateToolbar: 1147, + WindowDidZoom: 1148, + WindowFileDraggingEntered: 1149, + WindowFileDraggingExited: 1150, + WindowFileDraggingPerformed: 1151, + WindowHide: 1152, + WindowMaximise: 1153, + WindowUnMaximise: 1154, + WindowMinimise: 1155, + WindowUnMinimise: 1156, + WindowShouldClose: 1157, + WindowShow: 1158, + WindowWillBecomeKey: 1159, + WindowWillBecomeMain: 1160, + WindowWillBeginSheet: 1161, + WindowWillChangeOrderingMode: 1162, + WindowWillClose: 1163, + WindowWillDeminiaturize: 1164, + WindowWillEnterFullScreen: 1165, + WindowWillEnterVersionBrowser: 1166, + WindowWillExitFullScreen: 1167, + WindowWillExitVersionBrowser: 1168, + WindowWillFocus: 1169, + WindowWillMiniaturize: 1170, + WindowWillMove: 1171, + WindowWillOrderOffScreen: 1172, + WindowWillOrderOnScreen: 1173, + WindowWillResignMain: 1174, + WindowWillResize: 1175, + WindowWillUnfocus: 1176, + WindowWillUpdate: 1177, + WindowWillUpdateAlpha: 1178, + WindowWillUpdateCollectionBehavior: 1179, + WindowWillUpdateCollectionProperties: 1180, + WindowWillUpdateShadow: 1181, + WindowWillUpdateTitle: 1182, + WindowWillUpdateToolbar: 1183, + WindowWillUpdateVisibility: 1184, + WindowWillUseStandardFrame: 1185, + WindowZoomIn: 1186, + WindowZoomOut: 1187, + WindowZoomReset: 1188, } } @@ -412,50 +414,50 @@ type windowsEvents struct { func newWindowsEvents() windowsEvents { return windowsEvents{ - APMPowerSettingChange: 1188, - APMPowerStatusChange: 1189, - APMResumeAutomatic: 1190, - APMResumeSuspend: 1191, - APMSuspend: 1192, - ApplicationStarted: 1193, - SystemThemeChanged: 1194, - WebViewNavigationCompleted: 1195, - WindowActive: 1196, - WindowBackgroundErase: 1197, - WindowClickActive: 1198, - WindowClosing: 1199, - WindowDidMove: 1200, - WindowDidResize: 1201, - WindowDPIChanged: 1202, - WindowDragDrop: 1203, - WindowDragEnter: 1204, - WindowDragLeave: 1205, - WindowDragOver: 1206, - WindowEndMove: 1207, - WindowEndResize: 1208, - WindowFullscreen: 1209, - WindowHide: 1210, - WindowInactive: 1211, - WindowKeyDown: 1212, - WindowKeyUp: 1213, - WindowKillFocus: 1214, - WindowNonClientHit: 1215, - WindowNonClientMouseDown: 1216, - WindowNonClientMouseLeave: 1217, - WindowNonClientMouseMove: 1218, - WindowNonClientMouseUp: 1219, - WindowPaint: 1220, - WindowRestore: 1221, - WindowSetFocus: 1222, - WindowShow: 1223, - WindowStartMove: 1224, - WindowStartResize: 1225, - WindowUnFullscreen: 1226, - WindowZOrderChanged: 1227, - WindowMinimise: 1228, - WindowUnMinimise: 1229, - WindowMaximise: 1230, - WindowUnMaximise: 1231, + APMPowerSettingChange: 1189, + APMPowerStatusChange: 1190, + APMResumeAutomatic: 1191, + APMResumeSuspend: 1192, + APMSuspend: 1193, + ApplicationStarted: 1194, + SystemThemeChanged: 1195, + WebViewNavigationCompleted: 1196, + WindowActive: 1197, + WindowBackgroundErase: 1198, + WindowClickActive: 1199, + WindowClosing: 1200, + WindowDidMove: 1201, + WindowDidResize: 1202, + WindowDPIChanged: 1203, + WindowDragDrop: 1204, + WindowDragEnter: 1205, + WindowDragLeave: 1206, + WindowDragOver: 1207, + WindowEndMove: 1208, + WindowEndResize: 1209, + WindowFullscreen: 1210, + WindowHide: 1211, + WindowInactive: 1212, + WindowKeyDown: 1213, + WindowKeyUp: 1214, + WindowKillFocus: 1215, + WindowNonClientHit: 1216, + WindowNonClientMouseDown: 1217, + WindowNonClientMouseLeave: 1218, + WindowNonClientMouseMove: 1219, + WindowNonClientMouseUp: 1220, + WindowPaint: 1221, + WindowRestore: 1222, + WindowSetFocus: 1223, + WindowShow: 1224, + WindowStartMove: 1225, + WindowStartResize: 1226, + WindowUnFullscreen: 1227, + WindowZOrderChanged: 1228, + WindowMinimise: 1229, + WindowUnMinimise: 1230, + WindowMaximise: 1231, + WindowUnMaximise: 1232, } } @@ -518,159 +520,160 @@ var eventToJS = map[uint]string{ 1075: "mac:ApplicationWillTerminate", 1076: "mac:ApplicationWillUnhide", 1077: "mac:ApplicationWillUpdate", - 1078: "mac:MenuDidAddItem", - 1079: "mac:MenuDidBeginTracking", - 1080: "mac:MenuDidClose", - 1081: "mac:MenuDidDisplayItem", - 1082: "mac:MenuDidEndTracking", - 1083: "mac:MenuDidHighlightItem", - 1084: "mac:MenuDidOpen", - 1085: "mac:MenuDidPopUp", - 1086: "mac:MenuDidRemoveItem", - 1087: "mac:MenuDidSendAction", - 1088: "mac:MenuDidSendActionToItem", - 1089: "mac:MenuDidUpdate", - 1090: "mac:MenuWillAddItem", - 1091: "mac:MenuWillBeginTracking", - 1092: "mac:MenuWillDisplayItem", - 1093: "mac:MenuWillEndTracking", - 1094: "mac:MenuWillHighlightItem", - 1095: "mac:MenuWillOpen", - 1096: "mac:MenuWillPopUp", - 1097: "mac:MenuWillRemoveItem", - 1098: "mac:MenuWillSendAction", - 1099: "mac:MenuWillSendActionToItem", - 1100: "mac:MenuWillUpdate", - 1101: "mac:WebViewDidCommitNavigation", - 1102: "mac:WebViewDidFinishNavigation", - 1103: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation", - 1104: "mac:WebViewDidStartProvisionalNavigation", - 1105: "mac:WindowDidBecomeKey", - 1106: "mac:WindowDidBecomeMain", - 1107: "mac:WindowDidBeginSheet", - 1108: "mac:WindowDidChangeAlpha", - 1109: "mac:WindowDidChangeBackingLocation", - 1110: "mac:WindowDidChangeBackingProperties", - 1111: "mac:WindowDidChangeCollectionBehavior", - 1112: "mac:WindowDidChangeEffectiveAppearance", - 1113: "mac:WindowDidChangeOcclusionState", - 1114: "mac:WindowDidChangeOrderingMode", - 1115: "mac:WindowDidChangeScreen", - 1116: "mac:WindowDidChangeScreenParameters", - 1117: "mac:WindowDidChangeScreenProfile", - 1118: "mac:WindowDidChangeScreenSpace", - 1119: "mac:WindowDidChangeScreenSpaceProperties", - 1120: "mac:WindowDidChangeSharingType", - 1121: "mac:WindowDidChangeSpace", - 1122: "mac:WindowDidChangeSpaceOrderingMode", - 1123: "mac:WindowDidChangeTitle", - 1124: "mac:WindowDidChangeToolbar", - 1125: "mac:WindowDidDeminiaturize", - 1126: "mac:WindowDidEndSheet", - 1127: "mac:WindowDidEnterFullScreen", - 1128: "mac:WindowDidEnterVersionBrowser", - 1129: "mac:WindowDidExitFullScreen", - 1130: "mac:WindowDidExitVersionBrowser", - 1131: "mac:WindowDidExpose", - 1132: "mac:WindowDidFocus", - 1133: "mac:WindowDidMiniaturize", - 1134: "mac:WindowDidMove", - 1135: "mac:WindowDidOrderOffScreen", - 1136: "mac:WindowDidOrderOnScreen", - 1137: "mac:WindowDidResignKey", - 1138: "mac:WindowDidResignMain", - 1139: "mac:WindowDidResize", - 1140: "mac:WindowDidUpdate", - 1141: "mac:WindowDidUpdateAlpha", - 1142: "mac:WindowDidUpdateCollectionBehavior", - 1143: "mac:WindowDidUpdateCollectionProperties", - 1144: "mac:WindowDidUpdateShadow", - 1145: "mac:WindowDidUpdateTitle", - 1146: "mac:WindowDidUpdateToolbar", - 1147: "mac:WindowDidZoom", - 1148: "mac:WindowFileDraggingEntered", - 1149: "mac:WindowFileDraggingExited", - 1150: "mac:WindowFileDraggingPerformed", - 1151: "mac:WindowHide", - 1152: "mac:WindowMaximise", - 1153: "mac:WindowUnMaximise", - 1154: "mac:WindowMinimise", - 1155: "mac:WindowUnMinimise", - 1156: "mac:WindowShouldClose", - 1157: "mac:WindowShow", - 1158: "mac:WindowWillBecomeKey", - 1159: "mac:WindowWillBecomeMain", - 1160: "mac:WindowWillBeginSheet", - 1161: "mac:WindowWillChangeOrderingMode", - 1162: "mac:WindowWillClose", - 1163: "mac:WindowWillDeminiaturize", - 1164: "mac:WindowWillEnterFullScreen", - 1165: "mac:WindowWillEnterVersionBrowser", - 1166: "mac:WindowWillExitFullScreen", - 1167: "mac:WindowWillExitVersionBrowser", - 1168: "mac:WindowWillFocus", - 1169: "mac:WindowWillMiniaturize", - 1170: "mac:WindowWillMove", - 1171: "mac:WindowWillOrderOffScreen", - 1172: "mac:WindowWillOrderOnScreen", - 1173: "mac:WindowWillResignMain", - 1174: "mac:WindowWillResize", - 1175: "mac:WindowWillUnfocus", - 1176: "mac:WindowWillUpdate", - 1177: "mac:WindowWillUpdateAlpha", - 1178: "mac:WindowWillUpdateCollectionBehavior", - 1179: "mac:WindowWillUpdateCollectionProperties", - 1180: "mac:WindowWillUpdateShadow", - 1181: "mac:WindowWillUpdateTitle", - 1182: "mac:WindowWillUpdateToolbar", - 1183: "mac:WindowWillUpdateVisibility", - 1184: "mac:WindowWillUseStandardFrame", - 1185: "mac:WindowZoomIn", - 1186: "mac:WindowZoomOut", - 1187: "mac:WindowZoomReset", - 1188: "windows:APMPowerSettingChange", - 1189: "windows:APMPowerStatusChange", - 1190: "windows:APMResumeAutomatic", - 1191: "windows:APMResumeSuspend", - 1192: "windows:APMSuspend", - 1193: "windows:ApplicationStarted", - 1194: "windows:SystemThemeChanged", - 1195: "windows:WebViewNavigationCompleted", - 1196: "windows:WindowActive", - 1197: "windows:WindowBackgroundErase", - 1198: "windows:WindowClickActive", - 1199: "windows:WindowClosing", - 1200: "windows:WindowDidMove", - 1201: "windows:WindowDidResize", - 1202: "windows:WindowDPIChanged", - 1203: "windows:WindowDragDrop", - 1204: "windows:WindowDragEnter", - 1205: "windows:WindowDragLeave", - 1206: "windows:WindowDragOver", - 1207: "windows:WindowEndMove", - 1208: "windows:WindowEndResize", - 1209: "windows:WindowFullscreen", - 1210: "windows:WindowHide", - 1211: "windows:WindowInactive", - 1212: "windows:WindowKeyDown", - 1213: "windows:WindowKeyUp", - 1214: "windows:WindowKillFocus", - 1215: "windows:WindowNonClientHit", - 1216: "windows:WindowNonClientMouseDown", - 1217: "windows:WindowNonClientMouseLeave", - 1218: "windows:WindowNonClientMouseMove", - 1219: "windows:WindowNonClientMouseUp", - 1220: "windows:WindowPaint", - 1221: "windows:WindowRestore", - 1222: "windows:WindowSetFocus", - 1223: "windows:WindowShow", - 1224: "windows:WindowStartMove", - 1225: "windows:WindowStartResize", - 1226: "windows:WindowUnFullscreen", - 1227: "windows:WindowZOrderChanged", - 1228: "windows:WindowMinimise", - 1229: "windows:WindowUnMinimise", - 1230: "windows:WindowMaximise", - 1231: "windows:WindowUnMaximise", + 1078: "mac:DidReceiveNotificationResponse", + 1079: "mac:MenuDidAddItem", + 1080: "mac:MenuDidBeginTracking", + 1081: "mac:MenuDidClose", + 1082: "mac:MenuDidDisplayItem", + 1083: "mac:MenuDidEndTracking", + 1084: "mac:MenuDidHighlightItem", + 1085: "mac:MenuDidOpen", + 1086: "mac:MenuDidPopUp", + 1087: "mac:MenuDidRemoveItem", + 1088: "mac:MenuDidSendAction", + 1089: "mac:MenuDidSendActionToItem", + 1090: "mac:MenuDidUpdate", + 1091: "mac:MenuWillAddItem", + 1092: "mac:MenuWillBeginTracking", + 1093: "mac:MenuWillDisplayItem", + 1094: "mac:MenuWillEndTracking", + 1095: "mac:MenuWillHighlightItem", + 1096: "mac:MenuWillOpen", + 1097: "mac:MenuWillPopUp", + 1098: "mac:MenuWillRemoveItem", + 1099: "mac:MenuWillSendAction", + 1100: "mac:MenuWillSendActionToItem", + 1101: "mac:MenuWillUpdate", + 1102: "mac:WebViewDidCommitNavigation", + 1103: "mac:WebViewDidFinishNavigation", + 1104: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation", + 1105: "mac:WebViewDidStartProvisionalNavigation", + 1106: "mac:WindowDidBecomeKey", + 1107: "mac:WindowDidBecomeMain", + 1108: "mac:WindowDidBeginSheet", + 1109: "mac:WindowDidChangeAlpha", + 1110: "mac:WindowDidChangeBackingLocation", + 1111: "mac:WindowDidChangeBackingProperties", + 1112: "mac:WindowDidChangeCollectionBehavior", + 1113: "mac:WindowDidChangeEffectiveAppearance", + 1114: "mac:WindowDidChangeOcclusionState", + 1115: "mac:WindowDidChangeOrderingMode", + 1116: "mac:WindowDidChangeScreen", + 1117: "mac:WindowDidChangeScreenParameters", + 1118: "mac:WindowDidChangeScreenProfile", + 1119: "mac:WindowDidChangeScreenSpace", + 1120: "mac:WindowDidChangeScreenSpaceProperties", + 1121: "mac:WindowDidChangeSharingType", + 1122: "mac:WindowDidChangeSpace", + 1123: "mac:WindowDidChangeSpaceOrderingMode", + 1124: "mac:WindowDidChangeTitle", + 1125: "mac:WindowDidChangeToolbar", + 1126: "mac:WindowDidDeminiaturize", + 1127: "mac:WindowDidEndSheet", + 1128: "mac:WindowDidEnterFullScreen", + 1129: "mac:WindowDidEnterVersionBrowser", + 1130: "mac:WindowDidExitFullScreen", + 1131: "mac:WindowDidExitVersionBrowser", + 1132: "mac:WindowDidExpose", + 1133: "mac:WindowDidFocus", + 1134: "mac:WindowDidMiniaturize", + 1135: "mac:WindowDidMove", + 1136: "mac:WindowDidOrderOffScreen", + 1137: "mac:WindowDidOrderOnScreen", + 1138: "mac:WindowDidResignKey", + 1139: "mac:WindowDidResignMain", + 1140: "mac:WindowDidResize", + 1141: "mac:WindowDidUpdate", + 1142: "mac:WindowDidUpdateAlpha", + 1143: "mac:WindowDidUpdateCollectionBehavior", + 1144: "mac:WindowDidUpdateCollectionProperties", + 1145: "mac:WindowDidUpdateShadow", + 1146: "mac:WindowDidUpdateTitle", + 1147: "mac:WindowDidUpdateToolbar", + 1148: "mac:WindowDidZoom", + 1149: "mac:WindowFileDraggingEntered", + 1150: "mac:WindowFileDraggingExited", + 1151: "mac:WindowFileDraggingPerformed", + 1152: "mac:WindowHide", + 1153: "mac:WindowMaximise", + 1154: "mac:WindowUnMaximise", + 1155: "mac:WindowMinimise", + 1156: "mac:WindowUnMinimise", + 1157: "mac:WindowShouldClose", + 1158: "mac:WindowShow", + 1159: "mac:WindowWillBecomeKey", + 1160: "mac:WindowWillBecomeMain", + 1161: "mac:WindowWillBeginSheet", + 1162: "mac:WindowWillChangeOrderingMode", + 1163: "mac:WindowWillClose", + 1164: "mac:WindowWillDeminiaturize", + 1165: "mac:WindowWillEnterFullScreen", + 1166: "mac:WindowWillEnterVersionBrowser", + 1167: "mac:WindowWillExitFullScreen", + 1168: "mac:WindowWillExitVersionBrowser", + 1169: "mac:WindowWillFocus", + 1170: "mac:WindowWillMiniaturize", + 1171: "mac:WindowWillMove", + 1172: "mac:WindowWillOrderOffScreen", + 1173: "mac:WindowWillOrderOnScreen", + 1174: "mac:WindowWillResignMain", + 1175: "mac:WindowWillResize", + 1176: "mac:WindowWillUnfocus", + 1177: "mac:WindowWillUpdate", + 1178: "mac:WindowWillUpdateAlpha", + 1179: "mac:WindowWillUpdateCollectionBehavior", + 1180: "mac:WindowWillUpdateCollectionProperties", + 1181: "mac:WindowWillUpdateShadow", + 1182: "mac:WindowWillUpdateTitle", + 1183: "mac:WindowWillUpdateToolbar", + 1184: "mac:WindowWillUpdateVisibility", + 1185: "mac:WindowWillUseStandardFrame", + 1186: "mac:WindowZoomIn", + 1187: "mac:WindowZoomOut", + 1188: "mac:WindowZoomReset", + 1189: "windows:APMPowerSettingChange", + 1190: "windows:APMPowerStatusChange", + 1191: "windows:APMResumeAutomatic", + 1192: "windows:APMResumeSuspend", + 1193: "windows:APMSuspend", + 1194: "windows:ApplicationStarted", + 1195: "windows:SystemThemeChanged", + 1196: "windows:WebViewNavigationCompleted", + 1197: "windows:WindowActive", + 1198: "windows:WindowBackgroundErase", + 1199: "windows:WindowClickActive", + 1200: "windows:WindowClosing", + 1201: "windows:WindowDidMove", + 1202: "windows:WindowDidResize", + 1203: "windows:WindowDPIChanged", + 1204: "windows:WindowDragDrop", + 1205: "windows:WindowDragEnter", + 1206: "windows:WindowDragLeave", + 1207: "windows:WindowDragOver", + 1208: "windows:WindowEndMove", + 1209: "windows:WindowEndResize", + 1210: "windows:WindowFullscreen", + 1211: "windows:WindowHide", + 1212: "windows:WindowInactive", + 1213: "windows:WindowKeyDown", + 1214: "windows:WindowKeyUp", + 1215: "windows:WindowKillFocus", + 1216: "windows:WindowNonClientHit", + 1217: "windows:WindowNonClientMouseDown", + 1218: "windows:WindowNonClientMouseLeave", + 1219: "windows:WindowNonClientMouseMove", + 1220: "windows:WindowNonClientMouseUp", + 1221: "windows:WindowPaint", + 1222: "windows:WindowRestore", + 1223: "windows:WindowSetFocus", + 1224: "windows:WindowShow", + 1225: "windows:WindowStartMove", + 1226: "windows:WindowStartResize", + 1227: "windows:WindowUnFullscreen", + 1228: "windows:WindowZOrderChanged", + 1229: "windows:WindowMinimise", + 1230: "windows:WindowUnMinimise", + 1231: "windows:WindowMaximise", + 1232: "windows:WindowUnMaximise", } diff --git a/v3/pkg/events/events.txt b/v3/pkg/events/events.txt index 1d43adf5e..fa83f4655 100644 --- a/v3/pkg/events/events.txt +++ b/v3/pkg/events/events.txt @@ -52,6 +52,7 @@ mac:ApplicationWillResignActive mac:ApplicationWillTerminate mac:ApplicationWillUnhide mac:ApplicationWillUpdate +mac:DidReceiveNotificationResponse mac:MenuDidAddItem mac:MenuDidBeginTracking mac:MenuDidClose diff --git a/v3/pkg/events/events_darwin.h b/v3/pkg/events/events_darwin.h index bacaab781..5e6c1a39e 100644 --- a/v3/pkg/events/events_darwin.h +++ b/v3/pkg/events/events_darwin.h @@ -28,118 +28,119 @@ extern void processWindowEvent(unsigned int, unsigned int); #define EventApplicationWillTerminate 1075 #define EventApplicationWillUnhide 1076 #define EventApplicationWillUpdate 1077 -#define EventMenuDidAddItem 1078 -#define EventMenuDidBeginTracking 1079 -#define EventMenuDidClose 1080 -#define EventMenuDidDisplayItem 1081 -#define EventMenuDidEndTracking 1082 -#define EventMenuDidHighlightItem 1083 -#define EventMenuDidOpen 1084 -#define EventMenuDidPopUp 1085 -#define EventMenuDidRemoveItem 1086 -#define EventMenuDidSendAction 1087 -#define EventMenuDidSendActionToItem 1088 -#define EventMenuDidUpdate 1089 -#define EventMenuWillAddItem 1090 -#define EventMenuWillBeginTracking 1091 -#define EventMenuWillDisplayItem 1092 -#define EventMenuWillEndTracking 1093 -#define EventMenuWillHighlightItem 1094 -#define EventMenuWillOpen 1095 -#define EventMenuWillPopUp 1096 -#define EventMenuWillRemoveItem 1097 -#define EventMenuWillSendAction 1098 -#define EventMenuWillSendActionToItem 1099 -#define EventMenuWillUpdate 1100 -#define EventWebViewDidCommitNavigation 1101 -#define EventWebViewDidFinishNavigation 1102 -#define EventWebViewDidReceiveServerRedirectForProvisionalNavigation 1103 -#define EventWebViewDidStartProvisionalNavigation 1104 -#define EventWindowDidBecomeKey 1105 -#define EventWindowDidBecomeMain 1106 -#define EventWindowDidBeginSheet 1107 -#define EventWindowDidChangeAlpha 1108 -#define EventWindowDidChangeBackingLocation 1109 -#define EventWindowDidChangeBackingProperties 1110 -#define EventWindowDidChangeCollectionBehavior 1111 -#define EventWindowDidChangeEffectiveAppearance 1112 -#define EventWindowDidChangeOcclusionState 1113 -#define EventWindowDidChangeOrderingMode 1114 -#define EventWindowDidChangeScreen 1115 -#define EventWindowDidChangeScreenParameters 1116 -#define EventWindowDidChangeScreenProfile 1117 -#define EventWindowDidChangeScreenSpace 1118 -#define EventWindowDidChangeScreenSpaceProperties 1119 -#define EventWindowDidChangeSharingType 1120 -#define EventWindowDidChangeSpace 1121 -#define EventWindowDidChangeSpaceOrderingMode 1122 -#define EventWindowDidChangeTitle 1123 -#define EventWindowDidChangeToolbar 1124 -#define EventWindowDidDeminiaturize 1125 -#define EventWindowDidEndSheet 1126 -#define EventWindowDidEnterFullScreen 1127 -#define EventWindowDidEnterVersionBrowser 1128 -#define EventWindowDidExitFullScreen 1129 -#define EventWindowDidExitVersionBrowser 1130 -#define EventWindowDidExpose 1131 -#define EventWindowDidFocus 1132 -#define EventWindowDidMiniaturize 1133 -#define EventWindowDidMove 1134 -#define EventWindowDidOrderOffScreen 1135 -#define EventWindowDidOrderOnScreen 1136 -#define EventWindowDidResignKey 1137 -#define EventWindowDidResignMain 1138 -#define EventWindowDidResize 1139 -#define EventWindowDidUpdate 1140 -#define EventWindowDidUpdateAlpha 1141 -#define EventWindowDidUpdateCollectionBehavior 1142 -#define EventWindowDidUpdateCollectionProperties 1143 -#define EventWindowDidUpdateShadow 1144 -#define EventWindowDidUpdateTitle 1145 -#define EventWindowDidUpdateToolbar 1146 -#define EventWindowDidZoom 1147 -#define EventWindowFileDraggingEntered 1148 -#define EventWindowFileDraggingExited 1149 -#define EventWindowFileDraggingPerformed 1150 -#define EventWindowHide 1151 -#define EventWindowMaximise 1152 -#define EventWindowUnMaximise 1153 -#define EventWindowMinimise 1154 -#define EventWindowUnMinimise 1155 -#define EventWindowShouldClose 1156 -#define EventWindowShow 1157 -#define EventWindowWillBecomeKey 1158 -#define EventWindowWillBecomeMain 1159 -#define EventWindowWillBeginSheet 1160 -#define EventWindowWillChangeOrderingMode 1161 -#define EventWindowWillClose 1162 -#define EventWindowWillDeminiaturize 1163 -#define EventWindowWillEnterFullScreen 1164 -#define EventWindowWillEnterVersionBrowser 1165 -#define EventWindowWillExitFullScreen 1166 -#define EventWindowWillExitVersionBrowser 1167 -#define EventWindowWillFocus 1168 -#define EventWindowWillMiniaturize 1169 -#define EventWindowWillMove 1170 -#define EventWindowWillOrderOffScreen 1171 -#define EventWindowWillOrderOnScreen 1172 -#define EventWindowWillResignMain 1173 -#define EventWindowWillResize 1174 -#define EventWindowWillUnfocus 1175 -#define EventWindowWillUpdate 1176 -#define EventWindowWillUpdateAlpha 1177 -#define EventWindowWillUpdateCollectionBehavior 1178 -#define EventWindowWillUpdateCollectionProperties 1179 -#define EventWindowWillUpdateShadow 1180 -#define EventWindowWillUpdateTitle 1181 -#define EventWindowWillUpdateToolbar 1182 -#define EventWindowWillUpdateVisibility 1183 -#define EventWindowWillUseStandardFrame 1184 -#define EventWindowZoomIn 1185 -#define EventWindowZoomOut 1186 -#define EventWindowZoomReset 1187 +#define EventDidReceiveNotificationResponse 1078 +#define EventMenuDidAddItem 1079 +#define EventMenuDidBeginTracking 1080 +#define EventMenuDidClose 1081 +#define EventMenuDidDisplayItem 1082 +#define EventMenuDidEndTracking 1083 +#define EventMenuDidHighlightItem 1084 +#define EventMenuDidOpen 1085 +#define EventMenuDidPopUp 1086 +#define EventMenuDidRemoveItem 1087 +#define EventMenuDidSendAction 1088 +#define EventMenuDidSendActionToItem 1089 +#define EventMenuDidUpdate 1090 +#define EventMenuWillAddItem 1091 +#define EventMenuWillBeginTracking 1092 +#define EventMenuWillDisplayItem 1093 +#define EventMenuWillEndTracking 1094 +#define EventMenuWillHighlightItem 1095 +#define EventMenuWillOpen 1096 +#define EventMenuWillPopUp 1097 +#define EventMenuWillRemoveItem 1098 +#define EventMenuWillSendAction 1099 +#define EventMenuWillSendActionToItem 1100 +#define EventMenuWillUpdate 1101 +#define EventWebViewDidCommitNavigation 1102 +#define EventWebViewDidFinishNavigation 1103 +#define EventWebViewDidReceiveServerRedirectForProvisionalNavigation 1104 +#define EventWebViewDidStartProvisionalNavigation 1105 +#define EventWindowDidBecomeKey 1106 +#define EventWindowDidBecomeMain 1107 +#define EventWindowDidBeginSheet 1108 +#define EventWindowDidChangeAlpha 1109 +#define EventWindowDidChangeBackingLocation 1110 +#define EventWindowDidChangeBackingProperties 1111 +#define EventWindowDidChangeCollectionBehavior 1112 +#define EventWindowDidChangeEffectiveAppearance 1113 +#define EventWindowDidChangeOcclusionState 1114 +#define EventWindowDidChangeOrderingMode 1115 +#define EventWindowDidChangeScreen 1116 +#define EventWindowDidChangeScreenParameters 1117 +#define EventWindowDidChangeScreenProfile 1118 +#define EventWindowDidChangeScreenSpace 1119 +#define EventWindowDidChangeScreenSpaceProperties 1120 +#define EventWindowDidChangeSharingType 1121 +#define EventWindowDidChangeSpace 1122 +#define EventWindowDidChangeSpaceOrderingMode 1123 +#define EventWindowDidChangeTitle 1124 +#define EventWindowDidChangeToolbar 1125 +#define EventWindowDidDeminiaturize 1126 +#define EventWindowDidEndSheet 1127 +#define EventWindowDidEnterFullScreen 1128 +#define EventWindowDidEnterVersionBrowser 1129 +#define EventWindowDidExitFullScreen 1130 +#define EventWindowDidExitVersionBrowser 1131 +#define EventWindowDidExpose 1132 +#define EventWindowDidFocus 1133 +#define EventWindowDidMiniaturize 1134 +#define EventWindowDidMove 1135 +#define EventWindowDidOrderOffScreen 1136 +#define EventWindowDidOrderOnScreen 1137 +#define EventWindowDidResignKey 1138 +#define EventWindowDidResignMain 1139 +#define EventWindowDidResize 1140 +#define EventWindowDidUpdate 1141 +#define EventWindowDidUpdateAlpha 1142 +#define EventWindowDidUpdateCollectionBehavior 1143 +#define EventWindowDidUpdateCollectionProperties 1144 +#define EventWindowDidUpdateShadow 1145 +#define EventWindowDidUpdateTitle 1146 +#define EventWindowDidUpdateToolbar 1147 +#define EventWindowDidZoom 1148 +#define EventWindowFileDraggingEntered 1149 +#define EventWindowFileDraggingExited 1150 +#define EventWindowFileDraggingPerformed 1151 +#define EventWindowHide 1152 +#define EventWindowMaximise 1153 +#define EventWindowUnMaximise 1154 +#define EventWindowMinimise 1155 +#define EventWindowUnMinimise 1156 +#define EventWindowShouldClose 1157 +#define EventWindowShow 1158 +#define EventWindowWillBecomeKey 1159 +#define EventWindowWillBecomeMain 1160 +#define EventWindowWillBeginSheet 1161 +#define EventWindowWillChangeOrderingMode 1162 +#define EventWindowWillClose 1163 +#define EventWindowWillDeminiaturize 1164 +#define EventWindowWillEnterFullScreen 1165 +#define EventWindowWillEnterVersionBrowser 1166 +#define EventWindowWillExitFullScreen 1167 +#define EventWindowWillExitVersionBrowser 1168 +#define EventWindowWillFocus 1169 +#define EventWindowWillMiniaturize 1170 +#define EventWindowWillMove 1171 +#define EventWindowWillOrderOffScreen 1172 +#define EventWindowWillOrderOnScreen 1173 +#define EventWindowWillResignMain 1174 +#define EventWindowWillResize 1175 +#define EventWindowWillUnfocus 1176 +#define EventWindowWillUpdate 1177 +#define EventWindowWillUpdateAlpha 1178 +#define EventWindowWillUpdateCollectionBehavior 1179 +#define EventWindowWillUpdateCollectionProperties 1180 +#define EventWindowWillUpdateShadow 1181 +#define EventWindowWillUpdateTitle 1182 +#define EventWindowWillUpdateToolbar 1183 +#define EventWindowWillUpdateVisibility 1184 +#define EventWindowWillUseStandardFrame 1185 +#define EventWindowZoomIn 1186 +#define EventWindowZoomOut 1187 +#define EventWindowZoomReset 1188 -#define MAX_EVENTS 1188 +#define MAX_EVENTS 1189 #endif \ No newline at end of file