> For the complete documentation index, see [llms.txt](https://doc.batch.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.batch.com/developer/sdk/react-native/sdk-integration/rich-notifications-setup.md).

# Rich notifications setup

![Rich notification example](https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FXYiig9BzUVZaPDdzsujf%2Fios10_expanded_notif.jpg?alt=media\&token=7f44fa51-f21a-47ed-b0e0-1e8918c8d8ff)

iOS 10 introduced support for rich notifications: they can now contain custom content, such as images, videos, sounds or even a fully custom view controller.\
Batch comes with built-in support for these, but due to the way they're implemented, integration of a supplementary SDK is required.\
Don't worry, we've made it really easy.

## Expo Setup

If you are using Expo, just update your `app.json` file as following:

{% code title="app.json " %}

```json
{
  "expo": {
    ...,
    "plugins": [
      [
        "@batch.com/expo-plugin",
        {
          "iosApiKey": "YOUR_IOS_BATCH_API_KEY",
          "androidApiKey": "YOUR_ANDROID_BATCH_API_KEY",
          "enableIOSRichNotifications": true // <-- Add this
        }
      ]
    ],
  }
}
```

{% endcode %}

And if you are using EAS to build your application please also update your `app.json` file as following to declare the [ios app extension](https://docs.expo.dev/build-reference/app-extensions/):

{% code title="app.json" %}

```json
{
  "expo": {
  ...,
  "extra": {
      "eas": {
        "build": {
          "experimental": {
            "ios": {
              "appExtensions": [
                {
                  "targetName": "ExpoBatchRichNotifications",
                  "bundleIdentifier": "YOUR_BUNDLE_ID.ExpoBatchRichNotifications",
                  "entitlements": {
                    "com.apple.developer.usernotifications.service": true,
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}
```

{% endcode %}

## Bare React Native Setup

{% hint style="info" %}
Note: This tutorial assumes that you haven't already added a Notification Content extension. If you do, jump straight to [Integrating the Batch Extension SDK](#integrating-batch-extension-sdk).
{% endhint %}

### Adding a Notification Service Extension

In order to set up the Batch Extension SDK, you'll need a notification service extension. It's a standard iOS component that will take care of downloading rich content and add it to the notification.

Open your Xcode project, click on the `File` menu and then pick `New -> Target`. Then, pick `Notification Service Extension` and fill in what's left of the wizard. You can name the extension as you wish: we will name it `RichNotificationsExtension` for the rest of this tutorial.

![Xcode target wizard screenshot](https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2Fw7OuyEQcu9neBmslXAiI%2Fxcode_target_extension.png?alt=media\&token=511cf316-6a4e-45a0-8d8e-f35f621fb3af)

Xcode will then ask you if you want to activate the scheme. Press `Activate`.

Before going any further, you might want to check the extension's Deployment Target. It usually is the latest iOS minor, meaning that your extension will not run on older iOS versions.\
We recommend that you set it to the lowest version of iOS that your app supports, but not lower than iOS 10.0 as this is the version that introduced this extension kind.

![Xcode deployment target](https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2Fk2eL2z6gyLWNEBvY9tmC%2Fxcode_deployment_target.png?alt=media\&token=c8657ce5-eddb-4d85-bc90-23cc5c66b67d)

### Integrating Batch Extension SDK

{% hint style="info" %}
Note: If your application's target is linking libraries dynamically with usage of `use_framework!` please install the Swift BatchExtension by following the [framework integration guide](/developer/sdk/ios/sdk-integration/rich-notifications-setup.md#framework-integration).
{% endhint %}

Install the Batch Extension with the package manager of your choice.

{% tabs %}
{% tab title="SPM" %}
{% code title="Package.swift" %}

```
https://github.com/BatchLabs/Batch-iOS-SDK-Extension-ObjC.git
```

{% endcode %}
{% endtab %}

{% tab title="CocoaPods" %}
Make sure you're setting the dependency on the extension target. If your Podfile existed before you created your extension, you might need to add it.

{% code title="Podfile" %}

```
...
target 'RichNotificationsExtension' do
  pod 'BatchExtension-ObjC'
end
```

{% endcode %}
{% endtab %}

{% tab title="Carthage" %}
{% code title="Cartfile" %}

```
github "BatchLabs/Batch-iOS-SDK-Extension-ObjC"
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Automatic integration

If you don't have your own code, you've probably noticed that Xcode added some sample code for you:

![Default extension code](https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FLZt1w1TnBZCmj0BbdTh5%2Fextension_default_template.png?alt=media\&token=33505168-8f4f-4f3d-9c4d-f91467b546f5)

In order to have Batch automatically adding rich content to your notifications, simply remplace this code with:

{% tabs %}
{% tab title="Swift" %}

```swift
import BatchExtension

class NotificationService: BAENotificationServiceExtension {
    
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
// NotificationService.h -- 
@import BatchExtension;

@interface NotificationService : BAENotificationServiceExtension
@end

// NotificationService.m
#import "NotificationService.h"
@implementation NotificationService
@end

```

{% endtab %}
{% endtabs %}

That's it, no code to write! Start your app, and try sending a rich push from the dashboard.

#### Manual integration

If you've already added your own extension code, you might want to manually integrate Batch and perform your own modifications to the notification content. In this case, please follow the [iOS native documentation](/developer/sdk/ios/sdk-integration/rich-notifications-setup.md#manual-integration).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.batch.com/developer/sdk/react-native/sdk-integration/rich-notifications-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
