expo-notifications
@amazon-devices/expo-notifications provides an API to display, dismiss and list local notifications.
This is a system-deployed library and is available to React Native for Vega apps without a separate installation process. It is deployed as an autolinking library which your app links to at runtime. Compatibility is guaranteed only between the library and the version of React Native for Vega for which it is built.
Installation
- Add the JavaScript library dependency in the
package.jsonfile."dependencies": { ... "@amazon-devices/expo-notifications": "~2.0.0", "expo": "~50.0.0", ... } -
Reinstall dependencies using
npm installcommand. - Update your
manifest.tomlfile.[needs] ... [[needs.privilege]] id = "com.amazon.notification.privilege.post" [[needs.privilege]] id = "com.amazon.notification.privilege.query" - Rebuild your application with the
npm run build:appcommand
Examples
Example of scheduling, listing, and dismissing local notifications:
import * as Notifications from '@amazon-devices/expo-notifications';
import {
Importance,
InformationKind,
} from '@amazon-devices/expo-notifications/build/kepler';
import React, {useState} from 'react';
import {Button, StyleSheet, Text, View} from 'react-native';
export const App = () => {
const [result, setResult] = useState('');
const presentLocalNotificationAsync = async () => {
const id = await Notifications.scheduleNotificationAsync({
content: {
title: 'Test notification!',
subtitle: 'Subtitle',
body: 'This is the body',
data: {},
iconUri: 'https://example.org',
channel: {
name: 'Test channel',
description: 'Text channel for the demo app',
importance: {
importance: Importance.IMPORTANCE_LOW,
},
kind: new InformationKind(),
},
sound: false,
},
trigger: null,
});
setResult(`Displayed notification ${id}`);
};
const listLocalNotificationsAsync = async () => {
const res = await Notifications.getPresentedNotificationsAsync();
setResult(JSON.stringify(res, null, 2));
};
const countPresentedNotifications = async () => {
const presentedNotifications =
await Notifications.getPresentedNotificationsAsync();
setResult(`Count: ${presentedNotifications.length}`);
};
const dismissAll = async () => {
await Notifications.dismissAllNotificationsAsync();
setResult('Notifications dismissed');
};
const dismissSingle = async () => {
const presentedNotifications =
await Notifications.getPresentedNotificationsAsync();
if (!presentedNotifications.length) {
setResult('No notifications to be dismissed');
return;
}
const lastNotificationUuid = presentedNotifications[0].request.identifier;
await Notifications.dismissNotificationAsync(lastNotificationUuid);
setResult(`Notification ${lastNotificationUuid} dismissed`);
};
return (
<View style={styles.container}>
<Text style={styles.text}>Local Notifications</Text>
<Button
onPress={presentLocalNotificationAsync}
title="Present a notification immediately"
/>
<Button
onPress={listLocalNotificationsAsync}
title="List all notifications"
/>
<Button
onPress={countPresentedNotifications}
title="Count presented notifications"
/>
<Text style={styles.text}>Dismissing notifications</Text>
<Button onPress={dismissSingle} title="Dismiss a single notification" />
<Button onPress={dismissAll} title="Dismiss all notifications" />
<View style={{flex: 1}}>
{result && (
<Text style={styles.text}>
Last Result:{'\n'}
{result}
</Text>
)}
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
text: {
color: 'black',
fontSize: 32,
},
});
API reference
Check out the dedicated documentation page for info about this library, API reference and more: Official Expo documentation for expo-notifications.
Note that this documentation applies to all platforms and includes methods that are not supported on Vega.
Methods
| Method | Description | Platform support |
|---|---|---|
| addPushTokenListener | In rare situations, a push token may be changed by the push notification service while the app is running. When a token is rolled, the old one becomes invalid and sending notifications to it will fail. A push token listener will let you handle this situation gracefully by registering the new token with your backend right away. | Android, iOS |
| getDevicePushTokenAsync | Returns a native FCM, APNs token or a PushSubscription data that can be used with another push notification service. |
Android, iOS |
| getExpoPushTokenAsync | Returns an Expo token that can be used to send a push notification to the device using Expo's push notifications service. | Android, iOS |
| removePushTokenSubscription | Removes a push token subscription returned by an addPushTokenListener call. |
Android, iOS |
| addNotificationReceivedListener | Listeners registered by this method will be called whenever a notification is received while the app is running. | Android, iOS |
| addNotificationResponseReceivedListener | Listeners registered by this method will be called whenever a user interacts with a notification (for example, taps on it). | Android, iOS |
| addNotificationsDroppedListener | Listeners registered by this method will be called whenever some notifications have been dropped by the server. Applicable only to Firebase Cloud Messaging which we use as a notifications service on Android. It corresponds to onDeletedMessages() callback. More information can be found in Firebase docs. | Android, iOS |
| getLastNotificationResponseAsync | Returns the notification response that was received most recently (a notification response designates an interaction with a notification, such as tapping on it). | Android, iOS |
| removeNotificationSubscription | Removes a notification subscription returned by an addNotificationListener call. |
Android, iOS |
| setNotificationHandler | When a notification is received while the app is running, using this function you can set a callback that will decide whether the notification should be shown to the user or no. | Android, iOS |
| registerTaskAsync | When a notification is received while the app is backgrounded, using this function you can set a callback that will be run in response to that notification. Under the hood, this function is run using expo-task-manager. You must define the task first, with TaskManager.defineTask. Make sure you define it in the global scope. |
Android, iOS |
| unregisterTaskAsync | Used to unregister tasks registered with registerTaskAsync method. |
Android, iOS |
| getPermissionsAsync | Calling this function checks current permissions settings related to notifications. It lets you verify whether the app is currently allowed to display alerts, play sounds, etc. There is no user-facing effect of calling this. | Android, iOS |
| requestPermissionsAsync | Prompts the user for notification permissions according to request. Request defaults to asking the user to allow displaying alerts, setting badge count and playing sounds. | Android, iOS |
| getBadgeCountAsync | Fetches the number currently set as the badge of the app icon on device's home screen. A 0 value means that the badge is not displayed. |
Android, iOS |
| setBadgeCountAsync | Sets the badge of the app's icon to the specified number. Setting it to 0 clears the badge. On iOS, this method requires that you have requested the user's permission for allowBadge via requestPermissionsAsync, otherwise it will automatically return false. |
Android, iOS |
| cancelAllScheduledNotificationsAsync | Cancels all scheduled notifications. | Android, iOS |
| cancelScheduledNotificationAsync | Cancels a single scheduled notification. The scheduled notification of given ID will not trigger. | Android, iOS |
| getAllScheduledNotificationsAsync | Fetches information about all scheduled notifications. | Android, iOS |
| getNextTriggerDateAsync | Allows you to check what will be the next trigger date for given notification trigger input. | Android, iOS |
| presentNotificationAsync | Schedules a notification for immediate trigger. | Android, iOS |
| scheduleNotificationAsync | Schedules a notification to be triggered in the future. | All |
| dismissAllNotificationsAsync | Removes all application's notifications displayed in the notification tray (Notification Center). | All |
| dismissNotificationAsync | Removes notification displayed in the notification tray (Notification Center). | All |
| getPresentedNotificationsAsync | Fetches information about all notifications present in the notification tray (Notification Center). | All |
| deleteNotificationChannelAsync | Removes the notification channel. | Android |
| deleteNotificationChannelGroupAsync | Removes the notification channel group and all notification channels that belong to it. | Android |
| getNotificationChannelAsync | Fetches information about a single notification channel. | Android |
| getNotificationChannelGroupAsync | Fetches information about a single notification channel group. | Android |
| getNotificationChannelGroupsAsync | Fetches information about all known notification channel groups. | Android |
| getNotificationChannelsAsync | Fetches information about all known notification channels. | Android |
| setNotificationChannelAsync | Assigns the channel configuration to a channel of a specified name (creating it if need be). This method lets you assign given notification channel to a notification channel group. | Android |
| setNotificationChannelGroupAsync | Assigns the channel group configuration to a channel group of a specified name (creating it if need be). | Android |
| deleteNotificationCategoryAsync | Deletes the category associated with the provided identifier. | Android, iOS |
| getNotificationCategoriesAsync | Fetches information about all known notification categories. | Android, iOS |
| setNotificationCategoryAsync | Sets the new notification category. | Android, iOS |
| setAutoServerRegistrationEnabledAsync | Sets the registration information so that the device push token gets pushed to the given registration endpoint. | Android, iOS |
| unregisterForNotificationsAsync | Unsubscribes the current device from receiving push notifications. | Android, iOS |
Hooks
| Hook | Description | Platform support |
|---|---|---|
| useLastNotificationResponse | A React hook always returns the notification response that was received most recently (a notification response designates an interaction with a notification, such as tapping on it). | Android, iOS |
Implementaiton details
The library currently doesn't work on the Vega Virtual Device.
Push notifications, triggers for local notifications and app badges aren't supported on Vega.
List of supported methods:
scheduleNotificationAsyncgetPresentedNotificationsAsyncdismissNotificationAsyncdismissAllNotificationsAsync
This package also includes support for Vega's notification channels, but these are provided to the scheduleNotificationAsync when the notification is being set, instead of being created ahead of time like on Android. For this reason any Channel-related methods in @amazon-devices/expo-notifications are not implemented.
Supported versions
| NPM package version | Vega SDK version | Vega OS version | React Native version |
|---|---|---|---|
| ~2.0.0 | 0.23 and earlier | OS 1.1 (1401010009820) and earlier |
0.72 |
Additional resources
For information on additional libraries, see Supported Third-Party Libraries and Services.
Last updated: Aug 03, 2026

