<!--
{
  "availability" : [
    "macOS: 10.8.0 - 11.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSUserNotificationCenterDelegate/userNotificationCenter(_:didActivate:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSUserNotificationCenterDelegate(im)userNotificationCenter:didActivateNotification:"
  },
  "title" : "userNotificationCenter(_:didActivate:)"
}
-->

# userNotificationCenter(_:didActivate:)

Sent to the delegate when a user clicks on a user notification presented by the user notification center.

```
optional func userNotificationCenter(_ center: NSUserNotificationCenter, didActivate notification: NSUserNotification)
```

## Parameters

`center`

The user notification center.

`notification`

The user notification object.

## Discussion

This would be a good time to take action in response to user interacting with a specific notification.

To take an action when your application is launched as a result of a user clicking on a notification, be sure to implement the <doc://com.apple.documentation/documentation/AppKit/NSApplicationDelegate/applicationDidFinishLaunching(_:)> method in the application class that implements the <doc://com.apple.documentation/documentation/AppKit/NSApplicationDelegate> protocol. The notification parameter to that method has a `userInfo` dictionary, and if that dictionary has the `NSApplicationLaunchUserNotificationKey` key. The value of that key is the [`NSUserNotification`](/documentation/Foundation/NSUserNotification) object that caused the application to launch. The `NSUserNotification` object is delivered to the `NSApplication` delegate because that message will be sent before your application has a chance to set a delegate for the `NSUserNotificationCenter`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)