React Native Quickstart
This guide walks you through integrating PushEngage push notifications into a React Native application targeting Android and iOS. Estimated time: 15 minutes.
After completing this guide, your app will receive push notifications on both platforms. See the React Native SDK Reference for the full API.
Prerequisites
- React Native project with turbo module support (RN 0.78+)
- Firebase account (create one free) — required for Android
- Apple Developer account with a valid App ID — required for iOS
- APNs certificate or key (create one) — required for iOS
- PushEngage account and App ID (see Get Your App ID)
If you are using React Native 0.77.0 or earlier, install SDK version 0.0.1:
npm install @pushengage/[email protected]
Step 1 — Install the SDK
npm install @pushengage/pushengage-react-native
Step 2 — Android Setup
Firebase Cloud Messaging (FCM)
- Open the Firebase console and sign in.
- Click Add Project (or select an existing one).
- Click the Android icon to add an Android app.
- Enter your app's package name (found in
android/app/build.gradleunderapplicationId). - Download google-services.json and place it at
android/app/google-services.json. - Generate the Service Account JSON: Firebase console → Settings → Service accounts → Generate new private key.
- Retrieve the Sender ID: Firebase console → Settings → Cloud Messaging tab.
Connect to PushEngage Dashboard
- Log in to your PushEngage Dashboard.
- Navigate to Site Settings → Installation → Android SDK tab.
- Enter your Firebase Sender ID and upload the Service Account JSON.
- Click Update and copy the App ID.
Step 3 — iOS Setup
Open your iOS workspace:
your_project_name/ios/your_project_name.xcworkspace
Enable Xcode Capabilities
- Select the root project and choose your main app target.
- Go to Signing & Capabilities → + Capability → Push Notifications.
- Click + Capability → Background Modes, then check Remote notifications and Background fetch.
If Push Notifications is not visible: Apple Developer account → Certificates, Identifiers & Profiles → select your App ID → enable Push Notifications → return to Xcode.
Connect iOS to PushEngage Dashboard
- PushEngage Dashboard → Site Settings → Installation → iOS SDK tab.
- Upload your APNs certificate or key.
- Copy the App ID.
Step 4 — Add Notification Service Extension (iOS)
Create the Extension
- In Xcode, go to File → New → Target → Notification Service Extension → Next.
- Name it
PushEngageNotificationServiceExtension→ Finish. Click Cancel when prompted to activate. - Select the extension target and set Deployment Target to iOS 10 or above.
Configure Podfile
Open ios/Podfile. Inside the existing post_install block, add the lines shown below. Then add the new extension target at the bottom of the file:
# Inside your existing post_install block, add:
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
end
end
# At the bottom of Podfile, add:
target 'PushEngageNotificationServiceExtension' do
pod 'PushEngage', '0.0.6'
end
Run in the ios/ directory:
pod repo update
pod install
Implement the Extension
import UserNotifications
import PushEngage
@available(iOSApplicationExtension 10.0, *)
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
var request: UNNotificationRequest?
override func didReceive(
_ request: UNNotificationRequest,
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
) {
self.request = request
self.contentHandler = contentHandler
self.bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent
if let bestContent = bestAttemptContent {
PushEngage.didReceiveNotificationExtensionRequest(request, bestContentHandler: bestContent)
contentHandler(bestContent)
}
}
override func serviceExtensionTimeWillExpire() {
if let contentHandler = contentHandler,
let request = request,
let bestAttemptContent = bestAttemptContent {
guard let content = PushEngage.serviceExtensionTimeWillExpire(
request, content: bestAttemptContent
) else {
contentHandler(bestAttemptContent)
return
}
contentHandler(content)
}
}
}
Step 5 — Add Notification Content Extension (iOS, Optional)
- In Xcode, go to File → New → Target → Notification Content Extension → Next.
- Name it
PushEngageNotificationContentExtension→ Finish. Click Cancel when prompted. - Set Deployment Target to iOS 10 or above.
- Add to
ios/Podfileat the bottom:
target 'PushEngageNotificationContentExtension' do
pod 'PushEngage', '0.0.6'
end
Run pod install in the ios/ directory.
Step 6 — Add App Groups (iOS)
- Select your main app target in Xcode → Signing & Capabilities → + Capability → App Groups.
- Add a new App Group:
group.com.yourcompany.yourapp. - In your main app's
Info.plist, add:- Key:
PushEngage_App_Group_Key - Value:
group.com.yourcompany.yourapp
- Key:
- In
PushEngageNotificationServiceExtension/Info.plist, add the same key and value. - Select the extension target → enable the same App Group under Signing & Capabilities.
Step 7 — Initialize the SDK
In your root index.js:
import { AppRegistry } from 'react-native';
import PushEngage from '@pushengage/pushengage-react-native';
import App from './App';
PushEngage.setAppId('YOUR_APP_ID');
// Trigger the system permission prompt; on grant, the SDK auto-subscribes.
PushEngage.requestNotificationPermission();
AppRegistry.registerComponent('YourAppName', () => App);
For iOS, add PushEngage initialization to ios/AppDelegate.mm:
#import "AppDelegate.h"
@import PushEngage;
@implementation AppDelegate
- (instancetype)init {
self = [super init];
if (self) {
[PushEngage swizzleInjectionWithIsEnabled:YES];
}
return self;
}
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.moduleName = @"YourAppName";
self.initialProps = @{};
[PushEngage setInitialInfoFor:application with:launchOptions];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
completionHandler(UIBackgroundFetchResultNewData);
}
@end
Replace YOUR_APP_ID and YourAppName with your actual values.
Step 8 — Send a Test Notification
- Build and run on a physical device.
- Accept the notification permission prompt.
- In the PushEngage Dashboard → Campaign → Push Broadcasts → Create New Push Broadcast → send a test.
Troubleshooting
iOS build error: @import when C++ modules are disabled
In Xcode → your app target → Build Settings → Other C++ Flags → add -fcxx-modules.
iOS: notifications not received after correct setup
Verify PushEngage_App_Group_Key is in both the main app's Info.plist and the extension's Info.plist, with the identical App Group name.