Introducing subscribers import – subscribe your existing users and start engaging instantly!
Green urbanism: a key strategy for creating sustainable cities
Pushbase Team
Pushbase Team

Remote Push Notifications for Expo and React Native

A step-by-step walkthrough: from device registration to delivery metrics collection

Push notifications are one of the most effective ways to keep users engaged with your mobile app. They allow you to send timely updates, reminders, or alerts directly to a user’s device, even when the app isn’t open. For Expo developers, setting up push notifications is straightforward thanks to Expo’s built-in tools.

What Are Push Notifications?

A push notification is a short message sent from a server to a mobile device. Unlike in-app messages, push notifications can appear on the user’s lock screen, notification tray, or banner alerts, making them ideal for capturing attention.

Common use cases include:

  • Announcing new features or updates

  • Sending personalized offers or promotions

  • Reminding users about incomplete actions (like abandoned carts)

  • Delivering real-time alerts such as news or chat messages

How Push Notifications Work in Expo

With Expo, you don’t need to write native code to get started. Expo provides an easy-to-use push notification service:

  1. Device Registration – Your app requests permission from the user to send notifications. If granted, Expo generates a unique push token for that device.

  2. Sending a Notification – Your backend server (or a third-party service) uses the Expo Push API to send a message to the user’s token.

  3. Delivery to Device – Expo routes the notification through Apple Push Notification Service (APNs) or Firebase Cloud Messaging (FCM) to reach the user’s device.

  4. Collecting delivery report - Expo create push ticket for each pushed notification, you use that ticket to get delivery receipt information.

Device Registration

Before you can send push notifications, your app needs to register the device and request the user’s permission. Once granted, Expo generates a unique push token for that device. This token is like an address—you’ll use it later when sending notifications.

Expo provides expo-notification package to manage notification permissions, register device with push token, listen and display notifications.

After registering device, Expo notification package return push token which you save in your database as part of user profile information, you use that token in future when you are pushing that specific device.

1/**
2 * Install expo-notifications and expo-device package and configure your project
3 * for push notification.
4 * @see - https://docs.expo.dev/versions/latest/sdk/notifications/
5 */
6import * as Notifications from "expo-notifications";
7import * as Device from "expo-device";
8import { Platform } from "react-native";
9
10// Function to register for push notifications
11export async function registerForPushNotificationsAsync() {
12  let token;
13
14  // Check if the device supports push notifications
15  if (Device.isDevice) {
16    // Ask the user for permission
17    const { status: existingStatus } =
18      await Notifications.getPermissionsAsync();
19    let finalStatus = existingStatus;
20
21    if (existingStatus !== "granted") {
22      const { status } = await Notifications.requestPermissionsAsync();
23      finalStatus = status;
24    }
25
26    // If permission denied, exit early
27    if (finalStatus !== "granted") {
28      alert("Failed to get push token for notifications!");
29      return;
30    }
31
32    // Get the Expo push token
33    token = (await Notifications.getExpoPushTokenAsync()).data;
34    console.log("Expo Push Token:", token);
35    // This token should be saved in database for future use.
36  } else {
37    alert("Must use physical device for Push Notifications");
38  }
39
40  // For Android, you also need a channel to handle notifications
41  if (Platform.OS === "android") {
42    await Notifications.setNotificationChannelAsync("default", {
43      name: "default",
44      importance: Notifications.AndroidImportance.MAX,
45      vibrationPattern: [0, 250, 250, 250],
46      lightColor: "#FF231F7C",
47    });
48  }
49
50  return token;
51}

Sending a Notification

Once you have collected push tokens from your users, you can send notifications to them using the Expo Push API. This API acts as a gateway, routing your messages to either Apple (APNs) or Google (FCM) depending on the device.

Here’s a simple example using Node.js and fetch to send a notification:

1// expoPushToken should be retrieve from your database
2async function sendPushNotification(expoPushToken) {
3  const message = {
4    to: expoPushToken,
5    sound: "default",
6    title: "Hello from Expo 👋",
7    body: "This is a test notification sent via Expo Push API!",
8    data: { someData: "goes here" },
9  };
10
11  try {
12    const response = await fetch("https://exp.host/--/api/v2/push/send", {
13      method: "POST",
14      headers: {
15        Accept: "application/json",
16        "Accept-encoding": "gzip, deflate",
17        "Content-Type": "application/json",
18      },
19      body: JSON.stringify(message),
20    });
21
22    const pushTickets = await response.json();
23
24    /* Save push token in your database and  it will be used later
25    * for retrieving  delivery report.
26    t*/
27  } catch (error) {
28    /* Log error - You can use remote logging service like Sentry*/
29    console.error(error);
30  }
31}
32
33// Example usage
34sendPushNotification("ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]");
35

Delivery to Device

After you send a notification through the Expo Push API, Expo takes care of routing it to the correct platform service. You don’t have to deal with Apple or Google directly — Expo handles that complexity for you.

Here’s what happens step by step:

  1. Send push request from your server to Expo Push API

You send a request containing the push token and message payload to

bash
https://exp.host/--/api/v2/push/send

2. Expo send push request to correspond push provider (FCM or APN)

Expo validates the token, processes the payload, and forwards it to the correct provider:

  • APNs (Apple Push Notification Service) for iOS devices

  • FCM (Firebase Cloud Messaging) for Android devices

3. Push provider deliver notification to target device

Apple or Google handle the actual delivery. They ensure the message is queued and pushed to the right device, even if the app is closed.

4. Notification Appears

  • On iOS, the notification can show as a banner, alert, or lock screen message depending on user settings.

  • On Android, it appears in the notification tray, possibly with sound, vibration, or a badge count if you’ve configured it.

4. User Interaction

If the user taps the notification, your app opens, and you can handle any additional logic (e.g., deep linking to a specific screen).

Collecting Delivery Reports

When you send notifications through Expo, the API doesn’t just fire and forget. It gives you delivery receipts that tell you whether your notification was successfully handed off to Apple (APNs) or Google (FCM), or if something went wrong (like an invalid token).

  1. Send the Notification

    When you make a request to the Expo Push API, it responds with a ticket.

1{
2  "data": {
3    "id": "f33a9f4e-71f5-45c2-9dcd-1234567890ab"
4  }
5}

This id is a reference you can later use to check the delivery status.

2. Check the Receipt

After a short delay (a few seconds), you can query the receipts endpoint with the IDs you collected:

bash
POST https://exp.host/--/api/v2/push/getReceipts

with body:

1{
2  "ids": ["f33a9f4e-71f5-45c2-9dcd-1234567890ab"]
3}

3. Read the Status

Example response:

1{
2  "data": {
3    "f33a9f4e-71f5-45c2-9dcd-1234567890ab": {
4      "status": "ok"
5    }
6  }
7}

Or if there was a problem:

1{
2  "data": {
3    "f33a9f4e-71f5-45c2-9dcd-1234567890ab": {
4      "status": "error",
5      "message": "The recipient device is not registered with FCM",
6      "details": {
7        "error": "DeviceNotRegistered"
8      }
9    }
10  }
11}

If a push receipt shows a DeviceNotRegistered error, you should remove the push token and ask the user to subscribe again. This usually means the user has uninstalled your app on that device. Keep in mind, sending notifications to devices that are no longer registered may cause APNs or FCM to flag your app as spam.

Final Thought

When used effectively, push notifications provide a simple way to engage users—whether for transactional updates like payments or reservations, or for sharing the latest promotions.

At Pushbase, we offer a unified push notification service that manages device registration, audience segmentation, message sending and scheduling, automatic deep linking, delivery tracking, and more—all in one platform.

Start to engage your audience today

Subscribe users, segment audiences, define deep links, launch campaigns, and measure results — all in one lightweight tool for Expo apps.