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.
Push notifications in Expo: setup, permissions, tokens, server-side sending. Works on iOS and Android with one implementation. 15-minute guide.
Push notifications in Expo. One implementation for iOS and Android. 15-minute setup.
Prerequisites
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.
npx expo install expo-notifications expo-device expo-constants
{
"expo": {
"plugins": [
[
"expo-notifications",
{
"icon": "./assets/notification-icon.png",
"color": "#ffffff"
}
]
]
}
}
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]"
}
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 });
}
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' },
}),
});
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.
| 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.
Everything in this guide is already pre-configured in AI App Factory. 11 AI agents automate the rest.