# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.usegravity.app/gravity-server/push-notifications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
