> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/react-native/push-message/rn-ios-rich-push-message.md).

# iOS Rich Push Message

{% hint style="info" %}
This feature is supported in React Native SDK version 3.26.0 and above.
{% endhint %}

To display push messages with images in an iOS app, add a [Notification Service Extension](https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension) and complete the configuration below.

For details on iOS Rich Push Notifications, refer to [Rich Push Notification](https://developer.apple.com/documentation/usernotificationsui/customizing-the-appearance-of-notifications).

{% stepper %}
{% step %}
**Add Notification Service Extension to Your App**

Open your project by opening the `/ios/{APP_NAME}.xcworkspace` file with Xcode, then select `File > New > Target...` at the top of the project and choose `Notification Service Extension` as shown below.

![](/files/YrrG6oWI0ZBz0LaRmm35)

Enter an appropriate name and click `Finish`.

![](/files/RsjoLHTjgNNh5FjGUEq6)

You need to add the Hackle dependency to the `Extension` you added earlier in your `Podfile`.

Add the `Hackle` dependency as follows.

```ruby
target 'NotificationServiceExtension' do
  pod 'Hackle'
end
```

{% endstep %}

{% step %}
**Configure Minimum Deployment**

{% hint style="danger" %}
If the minimum supported version differs between the app and the extension, images may not be displayed depending on the app version.

e.g.) If the app's minimum supported version is iOS 15 and the extension's minimum supported version is iOS 18:

* iOS 15 and above, below iOS 18: images are not displayed.
* iOS 18 and above: images are displayed.
  {% endhint %}

The Notification Service Extension requires a separate minimum supported version specification from the app.

**It is recommended to set `Minimum Deployment` to the same version as the app.**

![](/files/NA5MzpBnhgSwca2NGLtw)
{% endstep %}

{% step %}
**Integrate with the Hackle SDK**

**Add Image to Push Message**

Add the `handleRichNotification` function in the `didReceive` function to handle push images.

{% tabs %}
{% tab title="NotificationServiceExtension.swift" %}

```swift
import UserNotifications
import Hackle

class NotificationService: UNNotificationServiceExtension {

    var defaultNotificationContent: UNNotificationContent?
    var contentHandler: ((UNNotificationContent) -> Void)?

    override func didReceive(
      _ request: UNNotificationRequest,
      withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
    ) {
        self.defaultNotificationContent = request.content
        self.contentHandler = contentHandler

        if Hackle.handleRichNotification(request: request, contentHandler: contentHandler) {
            return
        }

        contentHandler(request.content)
    }

    override func serviceExtensionTimeWillExpire() {
      if let contentHandler = contentHandler,
         let defaultNotificationContent = defaultNotificationContent {
            contentHandler(defaultNotificationContent)
        }
    }
}
```

{% endtab %}

{% tab title="NotificationServiceExtension.h (Objective-C)" %}

```objectivec
#import <UserNotifications/UserNotifications.h>
@import Hackle;

@interface NotificationService : UNNotificationServiceExtension

@end
```

{% endtab %}

{% tab title="NotificationServiceExtension.m (Objective-C)" %}

```objectivec
#import "NotificationService.h"

@interface NotificationService ()

@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;

@end

@implementation NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request
                   withContentHandler:(void (^)(UNNotificationContent *))contentHandler {
    self.defaultNotificationContent = request.content;
    self.contentHandler = contentHandler;

    if ([Hackle handleRichNotificationWithRequest:request contentHandler:contentHandler]) {
        return;
    }
    contentHandler(request.content);
}

- (void)serviceExtensionTimeWillExpire {
    self.contentHandler(self.bestAttemptContent);
}
@end
```

{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hackle.io/en/development-guide/react-native/push-message/rn-ios-rich-push-message.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
