> For the complete documentation index, see [llms.txt](https://docs.usegravity.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usegravity.app/gravity-server/push-notifications.md).

# Push Notifications

If you purchased a Gravity Native or Gravity Power plan, you can send push notifications from the server to mobile devices on iOS or Android.&#x20;

When a user provides permission in-app to send push notifications, a push token for their device is stored in the database.

## Sending Push Notifications

To send a notification, simple call the **send** method of the notification helper and pass an array of tokens, plus the message you want to send.

```javascript
const notification = require('./helper/notification')

const tokens = ['wX1JVaQrCXOdTgAHa3FP', 'bXzeupkfVIKlrIKwtOH2']

notification.send(tokens, {

  title: 'New User',
  body: 'A new user has just signed up to your app',

})
```

{% hint style="info" %}
You can also pass data and sounds, please [refer to the Expo documentation](https://docs.expo.io/push-notifications/overview/) for more information.
{% endhint %}

You will probably only ever send one-off notifications based on a user's actions, however if you need to send hundreds of messages simultaneously, you may want to consider [bulk sending.](https://github.com/expo/expo-server-sdk-node)

## Removing Tokens

{% hint style="danger" %}
Failing to stop sending notifications to an unregistered device may result in being banned from sending push notifications by Apple and/or Google.
{% endhint %}

If a user disables push notifications for your service at any point, Gravity will remove the device token from the database the next time you attempt to send a notification and there is a `DeviceNotRegistered` error.
