How It Works
- Configure credentials in the dashboard — paste your APNs
.p8key, FCM service account JSON, or enable Web Push (keypair generated server-side). - Register devices — your client app calls
register()fromusePushRegistrationat a moment that makes sense for your UX (settings screen, first-run prompt, etc.). The SDK handles permission, token retrieval, and server registration. - Send notifications — your backend calls
sublay.push.send({ userIds, title, body, data }). Sublay fans the message out to every registered device for those users across all platforms.
Dashboard Setup
Installing the bundle
Open Database → Bundles in the dashboard and installpush. Once provisioning completes, the Push Notifications settings page becomes active.
Configuring providers
Go to Settings → Push Notifications in the dashboard. Configure each platform you want to support: APNs (iOS)| Field | Description |
|---|---|
| Key ID | The 10-character key identifier from your Apple Developer account |
| Team ID | Your Apple Developer team ID |
| Bundle ID | Your app’s bundle identifier (e.g. com.example.myapp) |
| .p8 key | Contents of the .p8 private key file downloaded from Apple |
| Production | Toggle for sandbox vs. production APNs gateway (defaults to production) |
GET /vapid-public-key endpoint for use in your service worker.
Test-send UI
Each provider card in the dashboard includes a Send Test Push panel. Supply a platform, a device token or subscription, a title, and a body, then click Send Test Push to verify credentials before shipping.Client SDK — Registering Devices
UseusePushRegistration with the adapter for your platform. Call register() in response to a deliberate user action — not on mount — because requesting OS push permission is a one-shot prompt that users cannot undo.
register(). See usePushRegistration for the full API.
Server SDK — Sending Notifications
Callclient.push.send() from your backend whenever you want to notify users:
Device Lifecycle
- Re-registration: registering the same physical device again (same token or endpoint) updates the existing record instead of duplicating it.
- Device reassignment: if the same device is registered by a different user (e.g. a shared device after logout/login), the record is reassigned to the new user.
- Stale token cleanup: tokens or subscriptions permanently rejected by APNs, FCM, or Web Push during a send are automatically deleted — no separate cleanup pass is needed.
- Explicit logout: call
unregister()in your logout flow so the device stops receiving notifications after sign-out.
Hooks
usePushRegistration
Request permission, register a device, and unregister it on logout — with built-in adapters for Expo, React Native, and Web
API Endpoints
Register Device
POST /push-notifications/devicesDeregister Device
DELETE /push-notifications/devicesSend Push
POST /push-notifications/sendGet VAPID Public Key
GET /push-notifications/vapid-public-key
