> 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/flutter/push-message/flutter-ios-rich-push-message.md).

# iOS Rich Push Message

{% hint style="info" %}
This feature is supported in Flutter SDK 2.23.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 more details about 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 App**

Open the project by opening `/ios/Runner.xcworkspace` in Xcode, then select `File > New > Target...` from the top menu and choose `Notification Service Extension` as shown below.

![](/files/YrrG6oWI0ZBz0LaRmm35)

Enter an appropriate name and click `Finish`.

![](/files/RsjoLHTjgNNh5FjGUEq6)

{% tabs %}
{% tab title="Swift Package Manager Configuration" %}
If you are using Swift Package Manager in Flutter, add the `Hackle` framework to the `Extension`.

![](/files/kYNvJmI23KGmB71jOTpd)

![](/files/MuOfyZhcqNZgACcM33f9)

![](/files/QrOZxXz2phKQPO5O372J)
{% endtab %}

{% tab title="CocoaPods Configuration" %}
You must add the Hackle dependency to the `Extension` you added earlier in the `Podfile`.

Add the `Hackle` dependency as shown below.

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

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

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

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

ex) If the App minimum supported version is iOS 15 and the Extension minimum supported version is iOS 18:

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

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

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

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

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

**Add Image to Push Message**

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

{% tabs %}
{% tab title="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="Objective-C" %}

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

@interface NotificationService : UNNotificationServiceExtension

@end
```

```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:

```
GET https://docs.hackle.io/en/development-guide/flutter/push-message/flutter-ios-rich-push-message.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
