Installation
Learn how to install and setup Native Notify push notifications in React Native Expo apps.
Not an Expo app?:
Everything on this page assumes the Expo SDK path (native-notify +
registerNNPushToken()). If you are building with Flutter, bare React
Native without Expo modules, native Swift or Kotlin, start with
Universal Push (Any Framework) instead — same
service, native APNs/FCM tokens, no SDK required.
This video walks through the setup guide below:
Prerequisites
Create a free NativeNotify.com account
You must create a free NativeNotify.com account to get your App ID and App Token. You need an App ID and App Token for Native Notify push notifications to work.
Create a free Expo.dev account
You must create a free https://Expo.dev account for Native Notify push notifications to work.
System Requirements
- Node.js: Make sure you have Node.js installed. The project uses
npm, which comes with Node.js. Install Node.js from here. - NPM or Yarn: Since the project uses
npmcommands, ensure that npm is installed with Node.js. Alternatively, you can use Yarn if preferred.
To verify installation, run:
node -v
npm -v
Expo Setup
You need Expo installed in your React Native app in order for Native Notify push notifications to work. Native Notify push notifications work in Expo "managed workflow" and/or "bare workflow". You do NOT have to eject out of Expo to use Native Notify push notifications.
If you have not yet added Expo to your existing React Native app, visit this link to learn how to get Expo set up in your existing React Native app:
Installation and setup
Install Native Notify
Run the following commands in your Expo project terminal:
npm install native-notify
npx expo install expo-device expo-notifications expo-constants
expo-constantsis a required peer dependency — native-notify imports it to resolve your EASprojectId.expo-notificationsalso needs its config plugin in your app.json — it is required for push notifications in development builds and EAS builds:
{
"expo": {
"plugins": ["expo-notifications"]
}
}
Expo Go on Android (SDK 53+):
Push notifications are not supported in Expo Go on Android — Expo Go cannot mint push tokens. Use a development build instead (npx expo run:android or an EAS development build). The Notification Inbox still works in Expo Go with mode="indie".
Import Native Notify
In your App.js or index.js file (for Expo 50+), include this import at the top of the screen:
import registerNNPushToken from 'native-notify';
Check for Hook function
Make sure your App.js or index.js file (for Expo 50+) is a Hook function. Here is an example:
export default function AppPage() {
...
}
-
This link explains Hooks in detail: https://react.dev/reference/react/hooks
-
If you are using a class component, this link shows how to wrap a class component inside of a hook function allowing you to still use Native Notify in a class component: https://github.com/NativeNotify/wrap-class-in-hook
Paste register function
Inside of your App function, at the top of your App function, paste this code:
registerNNPushToken(app-id-number, 'app-token-string');
Here is a complete example:
import React, { useState, useEffect } from 'react';
import registerNNPushToken from 'native-notify';
export default function AppPage() {
registerNNPushToken(app-id-number, 'app-token-string');
return (
...
)
}
Optional: configure your credentials once
Instead of passing appId and appToken to every call, you can set them once — with a provider:
import { NativeNotifyProvider } from 'native-notify';
export default function App() {
return (
<NativeNotifyProvider appId={yourAppId} appToken="yourAppToken">
<Root />
</NativeNotifyProvider>
);
}
or at module scope (works for the plain, non-React functions):
import { NativeNotify } from 'native-notify';
NativeNotify.init({ appId: yourAppId, appToken: 'yourAppToken' });
Every function still accepts explicit ids, so nothing changes if you keep passing them — when the ids are omitted, they are resolved from NativeNotify.init() / <NativeNotifyProvider>. Inside a component you can read the active config with useNativeNotify().
Optional: registration callbacks and token rotation
registerNNPushToken(yourAppId, 'yourAppToken', {
onRegistered: (result) => console.log('native-notify ready:', result.expoPushToken),
onError: (error) => console.warn('native-notify registration failed:', error),
});
onRegistered(result)— called after the token was registered with Native Notify.onError(error)— called when registration (or a token-rotation re-registration) fails.watchTokenRotation(defaulttrue) — automatically re-registers when the device push token rotates (Android reinstall / applicationId change, iOS backup restore).
Registration retries once on failure and has a 10-second timeout. To run the raw token flow yourself, use the exported registerForPushNotificationsAsync() — it never throws, it reports:
import { registerForPushNotificationsAsync } from 'native-notify';
const result = await registerForPushNotificationsAsync();
if (result.status === 'success') {
// result.expoPushToken, result.devicePushToken, result.expoAndroidToken, ...
} else {
console.warn(result.reason); // 'skipped' or 'error'
}
Test if push notifications are working
Install eas-cli
Run the following commands in your Expo project terminal:
npm install -g eas-cli
eas login
If you have not logged into your eas account, run the following command in your terminal and follow the instructions:
eas login
eas init
Run the following command in your terminal and follow the instructions to ensure your project has a projectId (your app requires an eas projectId for push notifications to work):
eas init
This writes extra.eas.projectId into your app.json. Native Notify resolves it with Expo's recommended fallback chain:
Constants?.expoConfig?.extra?.eas?.projectId ?? Constants?.easConfig?.projectId
If neither value is present, registration fails with a clear "no EAS projectId found" message — see Expo's Configure projectId docs.
npx expo start
Run the following command in your terminal to start the dev server:
npx expo start
Then open the app — in Expo Go on iOS, or in a development build on Android (npx expo run:android or an EAS dev build).
Open your app
Open your app on your iOS phone or Android phone. If you have not downloaded the Expo Go app yet, here is the link:
Where push notifications work:
- iOS: physical iPhones (Expo Go included). iOS Simulators on Xcode 14+ (macOS 13+, iOS 16+) can also receive push.
- Android: physical phones and emulators with Google Play services — but not Expo Go (SDK 53+). Use a development build.
Send yourself a push notification
Post to this URL:
https://app.nativenotify.com/api/notification
Use this POST body (replacing the 'dateSent' with your current date as a string):
{
appId: app-id-as-a-number,
appToken: "app-token-as-a-string",
title: "Push title here as a string",
body: "Push message here as a string",
dateSent: "put your date here as a string"
}
Notes:
- If you are using a non-javascript based server language like Python, specify that this is an 'application/json' post type in your post header.
- Expo limits push notification payloads to 4 KiB (4096 bytes) — title, body, and
pushDataare counted together.
Alternative: Expo's push notifications tool. After your app registers, the device has an Expo push token (it starts with ExponentPushToken[). Paste it into https://expo.dev/notifications, add a title and body, and send — a quick way to verify device-side setup without the Native Notify API.