Registry / messaging / expo-notifications

expo-notifications

JSON →
library56.0.16jsnpmunverified

A comprehensive Expo module for managing push notifications in React Native and Expo apps. Current version 56.0.16 provides APIs to fetch push notification tokens, and to present, schedule, receive, and respond to notifications. It supports local and remote (push) notifications, notification channels (Android), and notification categories (interactive buttons). Includes TypeScript types. Part of the Expo ecosystem, requiring 'expo' as a peer dependency. Released ~monthly, often breaking with Expo SDK version bumps. Key differentiator: cross-platform push notification management integrated with Expo's build system, eliminating native code configuration for managed workflows.

npm install expo-notifications
INSTALL
IMPORT
SIG · EXPO-NOTIFICATIONS
E
expo-notifications
messagingjavascriptv56.0.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getExpoPushTokenAsync
import { getExpoPushTokenAsync } from 'expo-notifications';
const { getExpoPushTokenAsync } = require('expo-notifications');
ESM-only since SDK 46; CommonJS require works only with Metro bundler but not recommended.
scheduleNotificationAsync
import { scheduleNotificationAsync } from 'expo-notifications';
import scheduleNotificationAsync from 'expo-notifications';
Named export, not default.
addNotificationResponseReceivedListener
import { addNotificationResponseReceivedListener } from 'expo-notifications';
import { addNotificationResponseListener } from 'expo-notifications';
The deprecated name was 'addNotificationResponseListener' (renamed in SDK 46).
AndroidImportance
import { AndroidImportance } from 'expo-notifications';
Type export; used for notification channels.

Shows how to request permissions, get an Expo push token, schedule a local notification, and listen for notification responses.

import * as Notifications from 'expo-notifications'; import { Platform } from 'react-native'; async function registerForPushNotifications() { // Request permission const { status: existingStatus } = await Notifications.getPermissionsAsync(); let finalStatus = existingStatus; if (existingStatus !== 'granted') { const { status } = await Notifications.requestPermissionsAsync(); finalStatus = status; } if (finalStatus !== 'granted') { alert('Failed to get push token!'); return; } // Get Expo push token const token = (await Notifications.getExpoPushTokenAsync()).data; console.log('Expo push token:', token); // Schedule a local notification after 5 seconds await Notifications.scheduleNotificationAsync({ content: { title: 'Scheduled Notification', body: 'This is a test.' }, trigger: { seconds: 5 }, }); } // Listener for notification response (user taps notification) const subscription = Notifications.addNotificationResponseReceivedListener(response => { console.log('User tapped notification:', response); }); // Cleanup listener registerForPushNotifications();
Debug
Known issues
breakingIn SDK 46, the listener 'addNotificationResponseListener' was renamed to 'addNotificationResponseReceivedListener'. The old name is removed.
fix
Use 'addNotificationResponseReceivedListener' instead.
affects: >=46.0.0
breakingIn SDK 46, 'getExpoPushTokenAsync' no longer accepts a 'experienceId' parameter (use 'projectId' in the app config).
fix
Remove 'experienceId' argument; set 'owner' and 'projectId' in app.json / app.config.js.
affects: >=46.0.0
breakingIn SDK 49, notification triggers with 'timeInterval' (legacy) were removed. Use 'seconds' or 'dateComponents'.
fix
Replace 'timeInterval' with 'seconds' in trigger objects.
affects: >=49.0.0
deprecatedMethod 'addNotificationResponseListener' is deprecated since SDK 46.
fix
Use 'addNotificationResponseReceivedListener'.
affects: >=46.0.0
gotchaOn Android, you must define notification channels (AndroidNotificationChannel) before posting notifications or they will drop silently.
fix
Use 'setNotificationChannelAsync' to create a channel before scheduling notifications.
affects: *
gotchaPush token and notification scheduling require a physical device or Android emulator with Google Play Services on Android; iOS simulator does not support remote notifications.
fix
Test on physical device for push notifications.
affects: *
gotchaIf you use Expo Go, push notifications only work on physical devices, not simulators.
fix
Use a development build or EAS Build for simulators.
affects: *
Errors
Common errors & fixes
Error: 'getExpoPushTokenAsync' is not a function (it is undefined)
Using default import instead of named import: 'import Notifications from 'expo-notifications''
fix
Use: 'import { getExpoPushTokenAsync } from 'expo-notifications''
Error: Notifications.addNotificationResponseListener is not a function
Using the deprecated name 'addNotificationResponseListener' (removed in SDK 46+).
fix
Use 'addNotificationResponseReceivedListener'.
Error: 'AndroidImportance' is not exported from 'expo-notifications'
Attempted to import 'AndroidImportance' but it may be under 'expo-notifications/src' or wrong version; it's a TypeScript type.
fix
Ensure TypeScript usage: 'import { AndroidImportance } from 'expo-notifications';' and the module exports it.
Upgrade
Version history
56.0.16latest on npm
Audit
Dependencies
exporequiredPeer dependency required; module relies on Expo's runtime and native modules infrastructure.
Agent activity
21 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
expo-notifications — npm install expo-notifications · libregistry