For the complete documentation index, see llms.txt. This page is also available as Markdown.

iOS Rich Push Message

This feature is supported in React Native SDK version 3.26.0 and above.

To display push messages with images in an iOS app, add a Notification Service Extension and complete the configuration below.

For details on iOS Rich Push Notifications, refer to Rich Push Notification.

1

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.

Enter an appropriate name and click Finish.

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

Add the Hackle dependency as follows.

target 'NotificationServiceExtension' do
  pod 'Hackle'
end
2

Configure Minimum Deployment

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.

3

Integrate with the Hackle SDK

Add Image to Push Message

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

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)
        }
    }
}

Last updated