<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UserNotifications",
  "identifier" : "/documentation/UserNotifications/UNUserNotificationCenterDelegate/userNotificationCenter(_:willPresent:withCompletionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "User Notifications"
    ],
    "preciseIdentifier" : "c:objc(pl)UNUserNotificationCenterDelegate(im)userNotificationCenter:willPresentNotification:withCompletionHandler:"
  },
  "title" : "userNotificationCenter(_:willPresent:withCompletionHandler:)"
}
-->

# userNotificationCenter(_:willPresent:withCompletionHandler:)

Asks the delegate how to handle a notification that arrived while the app was running in the foreground.

```
optional func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping @Sendable (UNNotificationPresentationOptions) -> Void)
```

## Parameters

`center`

The shared user notification center object that received the notification.

`notification`

The notification that is about to be delivered. Use the information in this object to determine an appropriate course of action. For example, you might use the information to update your app’s interface.

`completionHandler`

The block to execute with the presentation option for the notification. Always execute this block at some point during your implementation of this method. Use the `options` parameter to specify how you want the system to alert the user, if at all. This block has no return value and takes the following parameter:

- options: The option for notifying the user. Specify [`UNNotificationPresentationOptionNone`](/documentation/UserNotifications/UNNotificationPresentationOptionNone) to silence the notification completely. Specify other values to interact with the user. For a list of possible options, see [`UNNotificationPresentationOptions`](/documentation/UserNotifications/UNNotificationPresentationOptions).

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> optional func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

If your app is in the foreground when a notification arrives, the shared user notification center calls this method to deliver the notification directly to your app. If you implement this method, you can take whatever actions are necessary to process the notification and update your app. When you finish, call the `completionHandler` block and specify how you want the system to alert the user, if at all.

If your delegate does not implement this method, the system behaves as if you had passed the [`UNNotificationPresentationOptionNone`](/documentation/UserNotifications/UNNotificationPresentationOptionNone) option to the `completionHandler` block. If you do not provide a delegate at all for the [`UNUserNotificationCenter`](/documentation/UserNotifications/UNUserNotificationCenter) object, the system uses the notification’s original options to alert the user.

---

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)