Add a device to the notification subscription list
When integrated into your app, the Pushbase SDK handles notification subscriptions and collects relevant device information to support reliable message delivery.
All data is collected at the time of subscription and is used solely to
support notification delivery and targeting.
Prerequisite : Before initiating a device subscription, you must first request
notification permissions using
expo-notifications.
Copy
import * as Notifications from "expo-notifications";export function requestPermissionsAsync() { return Notifications.requestPermissionsAsync({ ios: { allowAlert: true, allowBadge: true, allowSound: true, }, });}
Requesting a device subscription before notification permission is granted will result in an error.
After permission granted, subscribe device as below:
Copy
/* Import device subscription function */import { subscribeToNotifications } from "@pushbase/sdk";/* Later inside the app, subscribe device with optional user profile */subscribeToNotifications({ id: 1, name: "George Washington", email: "washington@wh.gov",});
We recommend including your app user’s profile information—such as id, name,
email, or phone—at the time of subscription. This allows you to easily
identify which user is associated with each subscribed device in the Pushbase
dashboard.