<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UserNotifications",
  "identifier" : "/documentation/UserNotifications/UNNotificationServiceExtension/didReceive(_:withContentHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "User Notifications"
    ],
    "preciseIdentifier" : "c:objc(cs)UNNotificationServiceExtension(im)didReceiveNotificationRequest:withContentHandler:"
  },
  "title" : "didReceive(_:withContentHandler:)"
}
-->

# didReceive(_:withContentHandler:)

Asks you to make any needed changes to the notification and notify the system when you’re done.

```
func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void)
```

## Parameters

`request`

The original notification request. Use this object to get the original content of the notification.

`contentHandler`

The block to execute with the modified content. This block has no return value and takes the following parameter:

- contentToDeliver: A [`UNNotificationContent`](/documentation/UserNotifications/UNNotificationContent) object with the content the system displays to the user.

## Discussion

Override this method and use it to modify the [`UNNotificationContent`](/documentation/UserNotifications/UNNotificationContent) object that the system delivers with the notification. At some point during your implementation, execute the `contentHandler` block and pass it your modified content. If you decide not to modify the content, call the `contentHandler` block with the original content from the `request` parameter.

You can modify any of the content from the original request. You might customize the content for the current user or replace it altogether. You can use this method to download images or movies and add them as attachments to the content. You may also modify the alert text as long as you don’t remove it. If the content object doesn’t contain any alert text, the system ignores your modifications and delivers the original notification content.

Your extension has a limited amount of time (no more than 30 seconds) to modify the content and execute the `contentHandler` block. If you don’t execute that block in a timely manner, the system calls your extension’s [`serviceExtensionTimeWillExpire()`](/documentation/UserNotifications/UNNotificationServiceExtension/serviceExtensionTimeWillExpire()) method to give you one last chance to execute the block. If you don’t, the system presents the notification’s original content to 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)