Push
The ScaleBun.push namespace — 6 members.
Push control namespace. Most apps only need {@link enablePush}; these are for the manual/custom provider path and diagnostics.
import ScaleBun from '@scalebun/react-native';
ScaleBun.push.<method>(…);Members#
| Member | Signature |
|---|---|
setToken | setToken(token: string): void |
getToken | getToken(): string | null |
emitForeground | emitForeground(message: PushNotification): void |
emitNotificationOpened | emitNotificationOpened(message: PushNotification): void |
status | status() |
teardown | teardown(): void |
Reference#
setToken#
ScaleBun.push.setToken(token: string): voidInject/rotate a token (manual provider) — syncs to the backend.
getToken#
ScaleBun.push.getToken(): string | nullCurrent push token, if acquired.
emitForeground#
ScaleBun.push.emitForeground(message: PushNotification): voidDeliver a foreground notification to registered callbacks (manual provider).
emitNotificationOpened#
ScaleBun.push.emitNotificationOpened(message: PushNotification): voidDeliver a notification-open event to registered callbacks (manual provider).
status#
ScaleBun.push.status()Current push status: selected adapter, usability, reason, token.
teardown#
ScaleBun.push.teardown(): voidTear down all push listeners.
Notes#
The Notifee integration is optional#
Notification-channel handling in the FCM adapter goes through @notifee/react-native, an optional
peer dependency. Without it, channel configuration is unavailable — and because Metro resolves
require() strings at bundle time, its absence needs the SDK's Metro config to stub the name. See
the exports reference.
Ordering#
init() before anything push-related
Token plumbing depends on initialised transport.
identify() before you expect to target a person
A token registered against an anonymous user can be pushed to as a device but cannot be reached by a campaign that targets a segment of people.
Register the foreground and opened handlers before permission is granted
A notification can arrive immediately after permission. Handlers attached afterwards miss it.
teardown() on sign-out
Otherwise the next user of that device inherits the previous user's push registration.
Limits and edge cases#
A token is per device and per install. Reinstalling produces a new one; the old one becomes invalid.
Delivery is never guaranteed. The platform push services drop notifications for battery, connectivity and rate reasons. Never build a flow that requires one to arrive.
setTokenoverrides the SDK's own registration. If you pass a token from another integration, you own keeping it current.These calls do not throw and are silent in release builds.