android and ios projects. If you use Expo prebuild or EAS development builds, use React Native Expo SDK.
Mental Model
React Native push has two layers:- The JavaScript layer calls
Sendrealm.initialize,requestPermission,login,trackEvent, and listener APIs. - The native layer receives FCM or APNs tokens, handles notification callbacks, displays notifications, and forwards events back to JavaScript.
Setup Order
Follow this order:- Upload Firebase and APNs credentials in Sendrealm.
- Install
@sendrealm/react-native. - Add Android
google-services.jsonand enable iOS Push Notifications capabilities. - Rebuild Android and iOS native apps.
- Add the iOS app delegate hooks.
- Initialize Sendrealm from JavaScript.
- Request notification permission after your app explains the value.
- Call
loginwhen the user signs in. - Send test pushes on Android and iOS.
Requirements
- React 18 or newer
- React Native 0.72 or newer
- Android device or emulator with Google Play services
- Physical iOS device for APNs testing
- A Sendrealm app ID from the dashboard
- Firebase credentials uploaded for Android delivery
- APNs credentials uploaded for iOS delivery
- Push Notifications enabled on the iOS Apple Developer App ID and Xcode target
Install
Install the package:Installing the npm package is not enough by itself. Because this SDK contains native code, Android and iOS must be rebuilt before the native module is available.
Android Setup
Android push uses Firebase Cloud Messaging. Before testing Android:- The device or emulator must have Google Play services.
- The Firebase Android app package name must match your React Native Android
applicationId. google-services.jsonmust be added to the native Android app.- The Firebase service account JSON must be uploaded in Sendrealm.
- The app must be rebuilt after installing the SDK.
Generate google-services.json
Create or download the file from Firebase:
- Open the Firebase console.
- Select the Firebase project for your Android app.
- If you only have a Google Cloud project, add Firebase to that existing Google Cloud project from the Firebase console first.
- From the Firebase project overview, click the Android icon or Add app.
- Enter the exact package name from
android/app/build.gradle, usuallydefaultConfig.applicationId. - Click Register app.
- Click Download google-services.json.
- Move the file to:
google-services.json, not google-services (1).json.
Apply The Google Services Gradle Plugin
React Native bare apps are native Android projects, so the Firebase config file still needs the Google Services Gradle plugin. Inandroid/build.gradle or the root Gradle plugins block, make sure the plugin is available:
android/app/build.gradle, apply it to the app module:
Do Not Confuse The Two Firebase JSON Files
React Native Android setup uses both files:android/app/google-services.jsonin the app so Firebase client configuration is available.- Firebase service account private key JSON in Sendrealm so Sendrealm can send through FCM.
iOS AppDelegate Setup
iOS push uses APNs. iOS delivers APNs tokens through app delegate callbacks, so your app must forward those callbacks to Sendrealm. Add the Sendrealm React Native import and configure the module:apnsEnvironment: "sandbox" for development builds and apnsEnvironment: "production" for TestFlight or App Store builds.
iOS Capabilities In Xcode
Bare React Native apps have a real native iOS project, so iOS push setup is the same as a native Swift app. The JavaScript package cannot add Apple signing capabilities by itself. In Xcode:- Open
ios/<YourApp>.xcworkspace. - Select the iOS app project in the left navigator.
- Select the main app target.
- Open Signing & Capabilities.
- Click the add capability button.
- Add Push Notifications.
- Confirm the Team and Bundle Identifier match the app you configured in Apple Developer and Sendrealm.
iOS APNs Key For Sendrealm
Sendrealm needs an APNs private key uploaded in the dashboard before it can send to your React Native iOS app. Create the key in Apple Developer with these requirements:- The Apple Developer user must be an Account Holder or Admin.
- The key must have Apple Push Notification service selected.
- If Apple asks for scope, use Team Scoped for the simplest setup or Topic Specific for a stricter key.
- If you choose Topic Specific, include the exact Bundle ID used by the React Native iOS target.
- Download the
.p8file immediately because Apple only allows the private key to be downloaded once.
.p8 file, Key ID, Team ID, Bundle ID, and APNs environment in Sendrealm. Use sandbox for development builds installed from Xcode and production for TestFlight or App Store builds.
See Mobile Push Credentials for the full step-by-step APNs key walkthrough.
Initialize
Initialize once near app startup:Initialization Options
Common options:appId: required Sendrealm app ID from the dashboard.externalUserId: optional user ID to link during initialization.userEmail: optional user email to link during initialization.autoRequestPermission: whether the SDK should ask for notification permission during initialization.apnsEnvironment: iOS APNs environment, usuallysandboxfor development andproductionfor TestFlight or App Store.suppressForegroundNotifications: lets JavaScript handle foreground display instead of native display.foregroundPresentation: controls foreground display behavior.
autoRequestPermission: false and ask permission later.
Notification Permission
Ask for permission after your app explains the value:Identity
Calllogin after the user signs in:
logout when the user signs out:
login each time the active account changes.
Tags
Tags are app-sourced attributes. Use them for preferences, state, and behavior observed by the app:plan: "pro"preferredLanguage: "en"onboardingComplete: truelastViewedCategory: "orders"
Tags require the device to be linked to a contact. Call
login before adding user tags.Custom Events
Track custom events when the app observes behavior that should be available in Sendrealm:app_opened, checkout_started, lesson_completed, and order_viewed.
Notification Listeners
Use listeners when JavaScript needs to react to push activity while the app is running. Listen for notification opens:getInitialNotification soon after app startup. Cold-start open data is most useful before your navigation tree has already decided where to route the user.
Foreground Display
Control foreground display after initialization:suppressForegroundNotifications: true during initialization if JavaScript will render its own in-app notification UI instead of letting the native SDK display the notification.
Android Notification Channels
Android channels control notification importance, sound, vibration, and visibility. Create a channel when your app needs explicit channel behavior:Delivery Timing And OS Behavior
React Native apps still depend on native Android and iOS push behavior. The JavaScript API gives you one Sendrealm interface, but the final delivery and display rules come from Firebase Cloud Messaging, APNs, Android, and iOS. Notifications may be delayed, dropped, throttled, collapsed, or hidden when:- Android devices enter Doze or App Standby.
- Android battery optimization or OEM background limits restrict the app.
- Android notification channels are disabled or set to low importance.
- FCM normal-priority messages wait for a maintenance window.
- FCM lowers behavior after high priority is overused for non-visible messages.
- iOS background updates are throttled by APNs or iOS.
- iOS Focus, notification summary, or notification settings suppress display.
- The device is offline or the token is stale.
Diagnostics
Collect support-safe diagnostics during setup:- Device ID is present.
- Token is present.
- Permission is granted or has the expected status.
- Subscribed state is true unless the user opted out.
- Queue counts are empty or shrinking.
- Last SDK error is empty or explains the failure.
Testing Checklist
Before releasing:- Android test device has Google Play services.
- iOS test device is physical.
- Android package name matches Firebase.
- iOS App ID has Push Notifications enabled in Apple Developer.
- iOS app target has Push Notifications enabled in Xcode.
- iOS Bundle ID, Team ID, Key ID,
.p8, and APNs environment match the build. - The app rebuilds successfully after installing the SDK.
- iOS app delegate forwards APNs callbacks.
initializeresolves successfully.requestPermissionreturns the expected permission state.- A foreground push is received.
- A background push is received.
- Delayed delivery is acceptable for non-urgent campaigns.
- Time-sensitive notifications use visible platform-appropriate payloads.
- Tapping a push routes to the expected screen.
getSupportDiagnostics()shows token presence.
Troubleshooting
| Symptom | What to check |
|---|---|
| Expo Go fails to load the package | Use a development build or bare app because custom native code is required. |
Android token is null | Use a Google Play device or emulator and verify Firebase package name setup. |
| iOS signing fails after enabling push | Refresh automatic signing or regenerate the provisioning profile for the App ID. |
| iOS push entitlement is missing | Enable Push Notifications in both Apple Developer and the Xcode app target. |
| Silent pushes do not wake the app reliably | Confirm Background Modes, Remote notifications is enabled and treat silent delivery as best effort. |
| Notifications are delayed | Check Android Doze/App Standby, FCM priority, iOS APNs priority, Focus settings, and user notification settings. |
| Some pushes are missing | Check stale tokens, disabled notification channels, excessive pending messages, background-only payloads, and provider diagnostics. |
Tags return ContactNotLinked | Call login(userId, email) before tags. |
| Notification opens app but not URL | Check metadata.androidLaunchUrl, metadata.iosLaunchUrl, and native deep link configuration. |