<commit_before>---
title: Notifications
---

Provides access to remote notifications (also known as push notifications) and local notifications (scheduling and immediate) related functions.

Want to see it in action? Check out [this Snack](https://snack.expo.io/@documentation/pushnotifications)!

## Installation

This API is pre-installed in [managed](../../introduction/managed-vs-bare/#managed-workflow) apps. It is not available for [bare](../../introduction/managed-vs-bare/#bare-workflow) React Native apps, although there are some comparable libraries that you may use instead.

## API

```js
import { Notifications } from 'expo';
```

## Subscribing to Notifications

### `Notifications.addListener(listener)`

#### Arguments

-   **listener (_function_)** -- A callback that is invoked when a remote or local notification is received or selected, with a Notification object.

#### Returns

An [EventSubscription](#eventsubscription) object that you can call remove() on when you would like to unsubscribe the listener.

### Related types

### `EventSubscription`

Returned from `addListener`.

-   **remove() (_function_)** -- Unsubscribe the listener from future notifications.
    `Notification`

An object that is passed into each event listener when a notification is received:

-   **origin (_string_)** -- Either `selected` or `received`. `selected` if the notification was tapped on by the user, `received` if the notification was received while the user was in the app.
-   **data (_object_)** -- Any data that has been attached with the notification.
-   **remote (_boolean_)** -- `true` if the notification is a push notification, `false` if it is a local notification.

## Notifications

### `Notifications.getExpoPushTokenAsync()`

#### Returns

Returns a Promise that resolves to a token string. This token can be provided to the Expo notifications backend to send a push notification to this device. [Read more in the Push Notifications guide](../../guides/push-notifications/#push-notifications).

The Promise will be rejected if the app does not have permission to send notifications. Be sure to check the result of `Permissions.askAsync(Permissions.NOTIFICATIONS)` before attempting to get an Expo push token.

### `Notifications.presentLocalNotificationAsync(localNotification)`

Trigger a local notification immediately.

#### Arguments

-   **localNotification (_object_)** -- An object with the properties described in [LocalNotification](#localnotification).

#### Returns

A Promise that resolves to a unique notification id.

### `Notifications.scheduleLocalNotificationAsync(localNotification, schedulingOptions)`

Schedule a local notification to fire at some specific time in the future or at a given interval.

#### Arguments

-   **localNotification (_object_)** --

      An object with the properties described in [LocalNotification](#localnotification).

-   **schedulingOptions (_object_)** --

      An object that describes when the notification should fire.

    -   **time** (_date_ or _number_) -- A Date object representing when to fire the notification or a number in Unix epoch time. Example: `(new Date()).getTime() + 1000` is one second from now.
    -   **repeat** (_optional_) (_string_) -- `'minute'`, `'hour'`, `'day'`, `'week'`, `'month'`, or `'year'`.
    - (_Android only_) **intervalMs** (_optional_) (_number_) -- Repeat interval in number of milliseconds

#### Returns

A Promise that resolves to a unique notification id.

### `Notifications.dismissNotificationAsync(localNotificationId)`

_Android only_. Dismisses the notification with the given id.

#### Arguments

-   **localNotificationId (_number_)** -- A unique id assigned to the notification, returned from `scheduleLocalNotificationAsync` or `presentLocalNotificationAsync`.

### `Notifications.dismissAllNotificationsAsync()`

_Android only_. Clears any notifications that have been presented by the app.

### `Notifications.cancelScheduledNotificationAsync(localNotificationId)`

Cancels the scheduled notification corresponding to the given id.

#### Arguments

-   **localNotificationId (_number_)** -- A unique id assigned to the notification, returned from `scheduleLocalNotificationAsync` or `presentLocalNotificationAsync`.

### `Notifications.cancelAllScheduledNotificationsAsync()`

Cancel all scheduled notifications.

## Notification categories

A notification category defines a set of actions with which a user may respond to the incoming notification. You can read more about it [here (for iOS)](https://developer.apple.com/documentation/usernotifications/unnotificationcategory) and [here (for Android)](https://developer.android.com/guide/topics/ui/notifiers/notifications#Actions).

### `Notifications.createCategoryAsync(name: string, actions: ActionType[])`
<commit_msg>Update notifications.md<commit_after>---
title: Notifications
---

Provides access to remote notifications (also known as push notifications) and local notifications (scheduling and immediate) related functions.

Want to see it in action? Check out [this Snack](https://snack.expo.io/@documentation/pushnotifications)!

## Installation

This API is pre-installed in [managed](../../introduction/managed-vs-bare/#managed-workflow) apps. It is not available for [bare](../../introduction/managed-vs-bare/#bare-workflow) React Native apps, although there are some comparable libraries that you may use instead.

## API

```js
import { Notifications } from 'expo';
```

## Subscribing to Notifications

### `Notifications.addListener(listener)`

#### Arguments

-   **listener (_function_)** -- A callback that is invoked when a remote or local notification is received or selected, with a Notification object.

#### Returns

An [EventSubscription](#eventsubscription) object that you can call remove() on when you would like to unsubscribe the listener.

### Related types

### `EventSubscription`

Returned from `addListener`.

-   **remove() (_function_)** -- Unsubscribe the listener from future notifications.
    `Notification`

An object that is passed into each event listener when a notification is received:

-   **origin (_string_)** -- Either `selected` or `received`. `selected` if the notification was tapped on by the user, `received` if the notification was received while the user was in the app.
-   **data (_object_)** -- Any data that has been attached with the notification.
-   **remote (_boolean_)** -- `true` if the notification is a push notification, `false` if it is a local notification.

## Notifications

### `Notifications.getExpoPushTokenAsync()`

#### Returns

Returns a Promise that resolves to a token string. This token can be provided to the Expo notifications backend to send a push notification to this device. [Read more in the Push Notifications guide](../../guides/push-notifications/#push-notifications).

The Promise will be rejected if the app does not have permission to send notifications. Be sure to check the result of `Permissions.askAsync(Permissions.NOTIFICATIONS)` before attempting to get an Expo push token.

### `Notifications.presentLocalNotificationAsync(localNotification)`

Trigger a local notification immediately.

#### Arguments

-   **localNotification (_object_)** -- An object with the properties described in [LocalNotification](#localnotification).

#### Returns

A Promise that resolves to a unique notification id.

### `Notifications.scheduleLocalNotificationAsync(localNotification, schedulingOptions)`

Schedule a local notification to fire at some specific time in the future or at a given interval.

#### Arguments

-   **localNotification (_object_)** --

      An object with the properties described in [LocalNotification](#localnotification).

-   **schedulingOptions (_object_)** --

      An object that describes when the notification should fire.

    -   **time** (_date_ or _number_) -- A Date object representing when to fire the notification or a number in Unix epoch time. Example: `(new Date()).getTime() + 1000` is one second from now.
    -   **repeat** (_optional_) (_string_) -- `'minute'`, `'hour'`, `'day'`, `'week'`, `'month'`, or `'year'`.
    - (_Android only_) **intervalMs** (_optional_) (_number_) -- Repeat interval in number of milliseconds

#### Returns

A Promise that resolves to a unique notification id.

### `Notifications.dismissNotificationAsync(localNotificationId)`

_Android only_. Dismisses the notification with the given id.

#### Arguments

-   **localNotificationId (_number_)** -- A unique id assigned to the notification, returned from `scheduleLocalNotificationAsync` or `presentLocalNotificationAsync`.

### `Notifications.dismissAllNotificationsAsync()`

_Android only_. Clears any notifications that have been presented by the app.

### `Notifications.cancelScheduledNotificationAsync(localNotificationId)`

Cancels the scheduled notification corresponding to the given id.

#### Arguments

-   **localNotificationId (_number_)** -- A unique id assigned to the notification, returned from `scheduleLocalNotificationAsync` or `presentLocalNotificationAsync`.

### `Notifications.cancelAllScheduledNotificationsAsync()`

Cancel all scheduled notifications.

## Notification categories

A notification category defines a set of actions with which a user may interact with and respond to the incoming notification. You can read more about categories [here (for iOS)](https://developer.apple.com/documentation/usernotifications/unnotificationcategory) and [here (for Android)](https://developer.android.com/guide/topics/ui/notifiers/notifications#Actions).

Check out how to implement interactive Notifications in your app by taking a look at the code behind [this Snack](https://snack.expo.io/@documentation/interactivenotificationexample)

### `Notifications.createCategoryAsync(name: string, actions: ActionType[])`

{'fraction_non_alphanumeric': 0.10385786802030457, 'fraction_numerical': 0.0008121827411167512, 'mean_word_length': 4.981177899210686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4884970', 'n_tokens_mistral': 2493, 'n_tokens_neox': 2385, 'n_words': 1018}