Docs

React Native and Expo push notifications

Integrations

This guide adds React Native push notifications with PushFire, for bare React Native and for Expo. Your app gets an FCM token from React Native Firebase, registers it with the PushFire REST API, identifies the signed-in user and sets tags. Your server sends push and email and starts workflows. PushFire is the easiest lifecycle messaging platform for AI agents and vibe coders: push and email lifecycle campaigns, segments and workflows behind one small API.

A dedicated React Native package is coming soon. Until it ships, the app calls the REST API with fetch, as shown below. Do not use the pushfire npm package (0.1.1) in React Native: an update is in progress, and today it stores IDs in browser storage that React Native does not have.

Why you need React Native Firebase, not only expo-notifications

PushFire delivers through Firebase Cloud Messaging, and its API accepts FCM registration tokens only. expo-notifications gives an Expo push token, or a native device token from getDevicePushTokenAsync(). On Android that native token is an FCM token, but on iOS it is a raw APNs token, which PushFire cannot use. @react-native-firebase/messaging returns an FCM token on both platforms, so this guide uses it. You can still use expo-notifications to show notifications in the foreground.

Prerequisites

  • A PushFire account and project at console.pushfire.app, with your Firebase service account uploaded. See Create your first project.
  • A Public key (pf_pk_...) from Developers → API keys. It can register devices, identify subscribers and manage tags, and nothing else. See Public and Secret keys.
  • iOS and Android apps in the same Firebase project, with GoogleService-Info.plist and google-services.json.
  • For iOS: an APNs key uploaded in Firebase under Project settings → Cloud Messaging, and the Push Notifications capability.
  • For Expo: a development build. Expo Go cannot load the native Firebase modules.

Install React Native Firebase

Bare React Native:

Follow the React Native Firebase setup for the native files: google-services.json in android/app/, GoogleService-Info.plist in the iOS target, and the Google services Gradle plugin.

Expo (SDK 50 or later, development build):

Then build the app with npx expo run:android, npx expo run:ios or an EAS development build.

Initialize a small PushFire client

Every endpoint lives under https://api.pushfire.app/functions/v1. Every request sends Authorization: Bearer <key> and wraps its fields in a data object. In Expo, put the Public key in EXPO_PUBLIC_PUSHFIRE_PUBLIC_KEY.

Ask permission and register the device

Ask for permission, read the FCM token, and register the device once. Store deviceId and subscriberId in AsyncStorage, and update the same device when the token or permission changes. PushFire rejects a second registration of the same FCM token.

Send every device field. The keys osVersion, appVersion, manufacturer, model and language are required, but each may be null.

Identify the subscriber

When the user signs in, log the subscriber in with your own user ID as externalId. PushFire replaces the anonymous subscriber on this device. On sign-out, log out; PushFire gives the device a new anonymous subscriber.

Login ignores metadata. To store custom profile fields, call PATCH update-subscriber with the subscriber id and a metadata object.

Add, update and remove tags

Create the tag in Audience → Tags and use its UUID. A value is a string, a number of 1 or more, or null. Use add for a new tag and update to change its value.

Trigger a workflow and send push from your server

The Public key cannot start workflows or send messages. The API answers 403 "Client key cannot perform this action".

Warning: never ship a Secret key (pf_sk_) in a mobile app, browser bundle or no-code frontend. PushFire does not block a Secret key on a client, so the call works, but anyone can extract the key from your app and message all your users. Start workflows and send messages from your server, a Supabase Edge Function or your app builder's server function.

Call these endpoints from your backend with a Secret key. Batch push targets your externalId values. A workflow targets PushFire subscriber UUIDs or segment UUIDs. Values in notification.data must be strings, because FCM rejects other types.

Often you need no server call at all. A workflow with the "A subscriber enters a segment" start runs by itself when the app's tags move a subscriber into that segment. See Workflows.

For a full server, see Send push notifications from Node.js or Python.

Handle notifications in the app

When the app is in the background or closed, the OS shows PushFire notifications by itself. In the foreground, FCM hands the message to your code. Read your data payload there and show an in-app banner or a local notification.

Verify delivery

  1. Run a development build on a real device, allow notifications and sign in.
  2. Open Audience → Subscribers in the console. Find your externalId and check the device, push status and tags.
  3. Put the app in the background and send the curl request above.
  4. Check the notification, then open Developers → API Messages → Push Notifications for its status.

Troubleshooting

  • getToken hangs or fails on iOS: the APNs key is not uploaded in Firebase, the app lacks the Push Notifications capability, or you are on a simulator without push support.
  • "Native module RNFBAppModule not found" in Expo: you are in Expo Go. Build a development build.
  • 400 with "path": "data.model" (or another device field): a device key is missing. Send it with null.
  • 400 "Device with FCM token already exists": the app registered twice, often after AsyncStorage was cleared. Delete the token with deleteToken(getMessaging()) and register again.
  • 403 "Client key cannot perform this action": the app tried to send or start a workflow. Move that call to your server.
  • iOS notifications never arrive but Android works: the token came from expo-notifications instead of React Native Firebase, so PushFire received an APNs token.

FAQ

Does PushFire work with Expo?

Yes, with a development build. PushFire needs an FCM token, so the app uses @react-native-firebase/messaging with the @react-native-firebase/app and @react-native-firebase/messaging config plugins. Expo Go cannot load those native modules. EAS Build and npx expo run both work. The registration code in this guide is the same for Expo and bare React Native.

Can I use Expo push tokens with PushFire?

No. PushFire sends through Firebase Cloud Messaging, so it needs FCM registration tokens. An Expo push token only works with the Expo push service, and the iOS native token from getDevicePushTokenAsync() is an APNs token. Use React Native Firebase to get an FCM token on both iOS and Android.

Is there an official PushFire React Native SDK?

A dedicated React Native package is coming soon. Today you call the PushFire REST API with fetch and store two IDs in AsyncStorage, as this guide shows. The pushfire npm package is being updated and is not ready for React Native yet, because it relies on browser storage.

Is it safe to put the PushFire key in a React Native app?

Ship only the Public key (pf_pk_). Anyone can read it from the JavaScript bundle, so PushFire limits it to device, subscriber and tag calls. It cannot send push, send email or start workflows. Keep the Secret key on your server or in a Supabase Edge Function.

Next steps