Frage

My scenario: I have an app that sends a notification to the OS X Notification Center with a button. This notification is to tell me when someone rings our dock doorbell. The button is suppose to pull up a NSWindow that shows our dock camera. I can get the window to come up with a NSButton within the app, but I can't get it to come up with the notification button.

I have tried:

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
    if ([notification.title isEqualToString:@"Doorbell"]) {
        [DockCameraWindow makeKeyAndOrderFront:nil];
        NSLog(@"CameraWindow");
    }
    [[NSUserNotificationCenter defaultUserNotificationCenter] removeAllDeliveredNotifications];
}

The log shows up, however the window doesn't. My application however does take the front app status.

War es hilfreich?

Lösung

Did you try this :--

[NSApp activateIgnoringOtherApps:YES];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top