How to Add Push Notifications in Expo

Push notifications in Expo: setup, permissions, tokens, server-side sending. Works on iOS and Android with one implementation. 15-minute guide.

Learn/How to Add Push Notifications in Expo
beginner20 minutes

How to Add Push Notifications in Expo

Push notifications in Expo. One implementation for iOS and Android. 15-minute setup.

Prerequisites

Expo projectPhysical device for testing

The Quick Version

Expo provides expo-notifications — one API for both iOS and Android push notifications. No Firebase Cloud Messaging setup. No APNs configuration. Expo handles the platform routing.

Setup

1. Install

npx expo install expo-notifications expo-device expo-constants

2. Configure app.json

{
  "expo": {
    "plugins": [
      [
        "expo-notifications",
        {
          "icon": "./assets/notification-icon.png",
          "color": "#ffffff"
        }
      ]
    ]
  }
}

3. Request Permission and Get Token

import * as Notifications from 'expo-notifications';
import * as Device from 'expo-device';
import Constants from 'expo-constants';

async function registerForPushNotifications() {
  if (!Device.isDevice) {
    // Push notifications don't work on simulators
    return null;
  }

  const { status: existingStatus } = 
    await Notifications.getPermissionsAsync();
  
  let finalStatus = existingStatus;
  if (existingStatus !== 'granted') {
    const { status } = 
      await Notifications.requestPermissionsAsync();
    finalStatus = status;
  }

  if (finalStatus !== 'granted') {
    return null;
  }

  const token = await Notifications.getExpoPushTokenAsync({
    projectId: Constants.expiConfig?.extra?.eas?.projectId,
  });

  return token.data; // "ExponentPushToken[xxxx]"
}

4. Save the Token

Store the push token in your database (Supabase) associated with the user:

const token = await registerForPushNotifications();
if (token) {
  await supabase
    .from('user_push_tokens')
    .upsert({ user_id: userId, token, platform: Platform.OS });
}

5. Send from Server

From your NestJS backend:

const response = await fetch('https://exp.host/--/api/v2/push/send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    to: pushToken,
    title: 'New message',
    body: 'You have a new notification',
    data: { screen: 'messages' },
  }),
});

Gotchas I Hit

1. Simulators don't receive push notifications. Test on a real device. Always.

2. Token changes. Push tokens can change. Always re-register on app launch, not just on first install.

3. iOS background handling. iOS silently drops notifications if the payload is malformed. Test with the Expo push notification tool first.

4. Android channels. Android 8+ requires notification channels. Expo creates a default one, but you should create custom channels for different notification types.

Time to Implement

Step Time
Install packages 2 min
Permission flow 5 min
Token storage 5 min
Server-side sending 5 min
Testing on device 5 min
Total ~20 min

With AI App Factory, push notifications are pre-configured. Token storage, server sending, and notification handling are already wired.

Related

Or let AI App Factory handle this for you.

Everything in this guide is already pre-configured in AI App Factory. 11 AI agents automate the rest.

AI App FactoryLearnHow to Add Push Notifications in Expo