ReactNative push notifications

To setup push notification support with your React Native project, follow the below steps depending on what mobile platform you run your project on.


The Leanplum ReactNative SDK package does not include any push notifications packages and dependencies by default. This guide will follow you through the process of setting up and enabling notifications.

iOS React Native Push Setup

Below are steps to set up iOS push in Leanplum. Follow the below steps to add your certificates to the dashboard, then add the source code to receive a push with the Leanplum SDK.


Login to the iOS provisioning portal.


In the Identifiers > App IDs, select your app, click Edit, and enable Push Notifications.


Click Create Certificate for each of the Development and Production certificates and follow the onscreen instructions. You should not reuse existing certificates so that we can track delivery failures properly.


Download your new certificate files from your browser. Open the files on your computer, which will launch Keychain.


In Keychain, select the new certificates, expand them to view the private key, and then right click to export them as .p12 files. You must enter a password.


In Leanplum, go to your app's Keys & Settings (App Settings > {Your app} > Keys & Settings). Under Push Notifications, upload your .p12 files to Leanplum and enter your passphrase from step 5 above.


Configure your app to use push notifications in your app delegate's applicationDidFinishLaunching method.


If Push Notifications package is used, update the AppDelegate implementation to call the Push Notifications package methods. This enables the native iOS delegates to communicate with React Native code.

#import <RNCPushNotificationIOS.h>

// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
    [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    // Needs to be called if swizzling is disabled in Info.plist otherwise it won’t affect SDK if swizzling is enabled.
    [Leanplum didReceiveRemoteNotification:userInfo


- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    // Needs to be called if swizzling is disabled in Info.plist otherwise it won’t affect SDK if swizzling is enabled.
    [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    [Leanplum didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
    // Needs to be called if swizzling is disabled in Info.plist otherwise it won’t affect SDK if swizzling is enabled.
    [Leanplum didFailToRegisterForRemoteNotificationsWithError:error];

// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  [RNCPushNotificationIOS didReceiveLocalNotification:notification];


Request permissions for Push notifications.

A. Using ReactNative SDK 1.1.2+, you can call directly:
B. For older versions, request through the community package:

Install @react-native-community/push-notification-ios

yarn add @react-native-community/push-notification-ios


Installation Changes Depending on React Native Version

For React-Native 0.60 or newer (react-native >= 0.60) run:
cd ios && pod install

For React-Native 0.60 or older (react-native <= 0.59) run:
react-native link @react-native-community/push-notification-ios

Grant permission for the notifications after response from Leanplum SDK as shown below

import {Alert,Platform} from 'react-native';
import PushNotificationIOS from "@react-native-community/push-notification-ios";

Leanplum.onStartResponse((success: boolean) => {
  const alertTitle = success
  ? 'Leanplum session started'
  : 'Leanplum session not started';
  Platform.OS === 'ios' ? PushNotificationIOS.requestPermissions() : null;


Important iOS Setup Notes

For iOS push notifications to work with Leanplum, you'll also need to upload your .p12 certificates to Leanplum. Refer to the iOS SDK docs for instructions how to do that.

Also, we use swizzling to collect push tokens. If your app has other SDKs installed that also use method swizzling it may cause conflicts. See here for manual instructions.

Android React Native Setup

Below are steps to set up Android push in Leanplum. Follow the below steps to add activate push in the Leanplum dashboard and in your app.


To enable Push Notifications, you need to add the Leanplum FCM library in addition to the Firebase library to your project.
By default, only Leanplum core package is included (com.leanplum:leanplum-core:5.6.1). In order to use FCM, the core package needs to be replaced with the FCM package (com.leanplum:leanplum-fcm). Use the same version that comes with the Leanplum React Native SDK.


Modify the generated build.gradle file located in your android project directory. Ensure you have applied the plugin.

dependencies {
    // Use the Leanplum version that comes with the Leanplum RN SDK
    // remove the leanplum-core dependency, leanplum-fcm includes it 
    implementation 'com.leanplum:leanplum-fcm:5.3.3'
    implementation ''
apply plugin: ''


Ensure the classpath '' is set properly in the build.gradle's dependencies as shown in the example below:

dependencies {
        classpath ''


Include the Google Services JSON config. Add the google-services.json file in your <react_native_project>/android/app folder.


Ensure you have followed the above steps for each platform you want to enable notifications on.

The ReactNative SDK uses the iOS and Android SDKs under the hood. Troubleshooting and configuration articles for those SDKs are also valid for the ReactNative SDK.


If the following error is raised: Plugin with id '' not found, go back to STEP 3 and check whether the classpath '' is set properly.

Ensure you have also defined a Notification Channel in Leanplum. Follow the documentation article.


Ensure the correct certificates are uploaded to the Leanplum Dashboard:

  • Validate Sandbox and Prod certificates are uploaded to the corresponding fields on the Dashboard
  • Validate the bundle identifier matches exactly the app one.

Sending a Preview requires a registered test device with push enabled. The preview uses the Sandbox APNS certificate.
Sending an immediate, scheduled, triggered, or manual push, requires the user to be push enabled and to be running a Production built of the app - Ad Hoc, TestFlight, or App Store distribution. This uses the Production APNS certificate.