Requesting Permission and Getting a Push Token
Use expo-notifications to request notification permission, retrieve the Expo push token, and send the token to your backend server for storage.
What Are Push Notifications?
Push notifications are messages sent from your server to a user's device even when the app is closed. They appear in the device's notification center, show on the lock screen, and can trigger a badge count on the app icon. On mobile they are one of the most powerful re-engagement tools available.
The flow for push notifications involves three parties: your app (registers the device), your server (decides when to send), and a push gateway (Apple APNs for iOS, Google FCM for Android). Expo wraps both gateways with a unified push service.
Installing expo-notifications
The expo-notifications package provides a unified API for push notifications on both iOS and Android. Install it with the Expo CLI, which handles installing the correct native version for your Expo SDK.
Push notifications require a development build (not Expo Go) because they need APNs entitlements embedded in the iOS app binary. Android push works in Expo Go but iOS does not. For production, EAS Build handles the certificate configuration automatically.
// Install:
// npx expo install expo-notifications
// In app.json, configure notification appearance:
{
'expo': {
'notification': {
'icon': './assets/notification-icon.png',
'color': '#ffffff',
'androidMode': 'default',
'androidCollapsedTitle': '#{unread_notifications} new updates'
}
}
}All lessons in this course
- Requesting Permission and Getting a Push Token
- Sending Notifications via the Expo Push API
- Handling Foreground and Background Notifications
- Notification Channels and Rich Content