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.
When a user provides permission in-app to send push notifications, a push token for their device is stored in the database.

To send a notification, simple call the send method of the notification model and pass an array of tokens, plus the message you want to send.
const tokens = ['wX1JVaQrCXOdTgAHa3FP', 'bXzeupkfVIKlrIKwtOH2']
notification.send(tokens, {
title: 'New User',
body: 'A new user has just signed up to your app',
You can also pass data and sounds, please refer to the Expo documentation for more information.
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.

Failing to stop sending notifications to an unregistered device may result in being banned from sending push notifications by Apple and/or Google. 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.
Copy link
On this page
Sending Push Notifications
Removing Tokens