ScaleBun
Skip to article

Push

react-nativeDeveloperv0.1.0-alpha.4

The ScaleBun.push namespace — 6 members.

Updated Reviewed

Push control namespace. Most apps only need {@link enablePush}; these are for the manual/custom provider path and diagnostics.

TypeScript
import ScaleBun from '@scalebun/react-native';
ScaleBun.push.<method>(…);

Members#

MemberSignature
setTokensetToken(token: string): void
getTokengetToken(): string | null
emitForegroundemitForeground(message: PushNotification): void
emitNotificationOpenedemitNotificationOpened(message: PushNotification): void
statusstatus()
teardownteardown(): void

Reference#

setToken#

TypeScript
ScaleBun.push.setToken(token: string): void

Inject/rotate a token (manual provider) — syncs to the backend.

getToken#

TypeScript
ScaleBun.push.getToken(): string | null

Current push token, if acquired.

emitForeground#

TypeScript
ScaleBun.push.emitForeground(message: PushNotification): void

Deliver a foreground notification to registered callbacks (manual provider).

emitNotificationOpened#

TypeScript
ScaleBun.push.emitNotificationOpened(message: PushNotification): void

Deliver a notification-open event to registered callbacks (manual provider).

status#

TypeScript
ScaleBun.push.status()

Current push status: selected adapter, usability, reason, token.

teardown#

TypeScript
ScaleBun.push.teardown(): void

Tear 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#

  1. init() before anything push-related

    Token plumbing depends on initialised transport.

  2. 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.

  3. Register the foreground and opened handlers before permission is granted

    A notification can arrive immediately after permission. Handlers attached afterwards miss it.

  4. 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.

  • setToken overrides 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.

Push · API reference · React Native SDK · ScaleBun