Push notifications are a way to send messages to users who have installed your app. They are a great way to keep users engaged with your app. In Supersaas we use Expo Notifications to send push notifications to users.
Go to the component settings of your app and you will see the push notifications section.
app/(auth)/notification-settings.tsx
registerForPushNotificationsAsync().then((token) => {
if (token) {
// Call your API to save the token
} else {
toast.info(t("PUSH_NOTIFICATIONS:FAILED_TO_GET_PUSH_TOKEN"));
}
});
We have already implemented the registerForPushNotificationsAsync
function for you. It will return the push token if the user has granted the permission to receive push notifications. If the user has not granted the permission, it will return an error message.
Create a POST endpoint in your server to receive the Expo push token it in your database. When you send a notification from Supersaas dashboard, the token will be used to send the notification to the user. You can make use of Expo server SDK to send the notification to the user.
For more information on Expo notifications, refer to the official Expo documentation.