Notify
Send iOS and Android push notifications through APNs and FCM with Ubriot Notify and the @ubriot/notify-rn SDK.
Ubriot Notify sends iOS and Android push notifications directly to APNs and FCM, with retries, campaigns and delivery logs.
1. Upload push credentials
ubriot push setup --app myapppush setup reads your Expo config for the bundle identifier and Android package, finds your APNs .p8 key and Firebase service account JSON in the project (or asks for their paths), uploads them, and creates a backend server key. Pass --platform ios or --platform android to set up one platform.
You can also upload them one at a time (see Credentials) or in the dashboard under Credentials: an APNs auth key (.p8 with Key ID, Team ID and Bundle ID) for iOS, and a Firebase service account JSON from the Firebase console for Android.
2. Install the SDK
npm install @ubriot/notify-rnNo other dependencies. It works with expo-notifications, react-native-firebase or any library that gives you a native push token.
3. Register at app launch
Get the native APNs or FCM token however your app already does it, then pass it to Ubriot:
import { useEffect } from "react";
import { Platform } from "react-native";
import * as Notifications from "expo-notifications";
import { UbriotNotify } from "@ubriot/notify-rn";
useEffect(() => {
async function register() {
const { data: nativeToken } = await Notifications.getDevicePushTokenAsync();
await UbriotNotify.register({
appId: "your-app-id",
nativeToken,
platform: Platform.OS === "ios" ? "ios" : "android",
userId: currentUser?.id,
});
}
register();
}, []);register() is idempotent, so it is safe to call on every launch. userId is optional and links the device to a user in your system.
4. Send from your backend
Create a server key with ubriot push create-server-key --app myapp (or let push setup create one). It is shown once as UBRIOT_PUSH_SERVER_KEY; store it in your backend's environment. Then send:
curl -X POST https://api.ubriot.dev/api/v1/ubriot/push/send \
-H "X-Ubriot-Push-Key: $UBRIOT_PUSH_SERVER_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": ["UbriotPushToken[abc123...]"],
"title": "New message",
"body": "Alice replied to your post",
"data": { "screen": "chat", "threadId": "42" }
}'ubriot push list-server-keys --app myapp lists keys and ubriot push revoke-server-key <keyId> revokes one. Existing keys cannot be shown again; create a new one if it is lost.
5. Broadcast campaigns
To send to every registered device at once, open Notify, then Campaigns in the dashboard and choose Send campaign. Pick a platform filter (all, iOS or Android), write the notification and send. Delivery counts appear as soon as APNs and FCM respond.
SDK reference
UbriotNotify.register(options)
Registers a native push token and returns { pushToken, platform }, where pushToken is a stable Ubriot push token to send to.
| Option | Type | Meaning |
|---|---|---|
appId | string or number | Your Ubriot app id. Required. |
nativeToken | string | The APNs or FCM device token. Required. |
platform | "ios" or "android" | Required. |
userId | string or number | Optional. Calls identifyUser after registering. |
apiUrl | string | Optional. Defaults to https://api.ubriot.dev/api/v1. |
UbriotNotify.identifyUser(userId, options)
Links a device to a user id in your system. Call it after login with { appId, pushToken }, where pushToken comes from register(). apiUrl is optional.