React Native Bridge Method Reference
This reference documentation details the BubblBridge API available in your React Native environment. These methods are the JavaScript interface to the native Android and iOS SDKs.
1. SDK Initialization and Permissions
Use these methods to configure the SDK and handle the system-level access required for location tracking and notifications:
boot(apiKey, env, options) / init(apiKey, options)
Initializes native SDK runtime. init is a convenience alias for boot.
apiKey: string: Your unique Bubbl API key (string)env:STAGINGorPRODUCTIONoptionssegmentationTags?: string[]: Initial user tagsgeoPollIntervalMs?: number: How often to poll for geofencesdefaultDistance?: number(Android only) Default radius for zones
Permission Checks
requiredPermissions(): Returns a promise with an array of required platform constants (Android) or logical names likelocationAlways(iOS).locationGranted(): ReturnsPromise<boolean>for current location access.notificationGranted(): ReturnsPromise<boolean>for current push access.requestPushPermission(): Triggers the system prompt (iOS) or returns true for the Android manual flow.
2. Configuration and Privacy
Retrieve and refresh SDK configuration data and privacy legal text.
getCurrentConfiguration(): Returns the cached configuration payload as aPromise<Configuration | null>
Type Definition:
type Configuration = {
notificationsCount: number;
daysCount: number;
batteryCount: number;
privacyText: string;
};
Privacy Text Methods:
-
getPrivacyText(): Returns the cached privacy text as aPromise<string> -
refreshPrivacyText(): Refreshes configuration from the server and returns the latest privacy text.
3. Location and Geofencing
These methods manage real-time location tracking and the synchronization of geofence-based campaigns.
-
startLocationTracking(): Starts location tracking / permission escalation where needed. -
refreshGeofence(lat, lng): Triggers an immediate local geofence refresh for specific coordinates. -
startGeofenceUpdates(): Starts the stream of geofence snapshots from the native layer to JS. -
stopGeofenceUpdates(): Stops the geofence snapshot stream. -
forceRefreshCampaigns(): Forces campaign refresh using last-known or fallback location. -
hasCampaigns(): ReturnsPromise<boolean>based on currently loaded geofence data. -
getCampaignCount():Returns the count of loaded campaigns currently in memory. -
clearCachedCampaigns():Clears local campaign cache when supported by native SDK.
4. User Segmentation and Identity
Use these methods to identify users and target campaigns based on custom behavioral tags.
updateSegments(segmentations: string[]): Pushes an array of strings as segmentation tags for the current device.setCorrelationId(correlationId: string): Sets or overrides persistentcorrelation_idfor the current install.getCorrelationId(): Retrieves the currentcorrelation_id(returns an empty string if unset).clearCorrelationId(): Explicitly removes the storedcorrelation_id.
Notification and Survey Analytics
Bubbl relies on interaction data to populate your dashboard. Ensure you call these methods when users interact with your UI.
sendEvent(params): A generic event reporting endpoint wrapper returning aPromise<boolean>
Type Definition:
type BubblSendEventParams = {
curatedNotificationID: string;
locationID: string;
type: string;
activity: string;
latitude: number;
longitude: number;
};
Interaction helpers
-
trackSurveyEvent(notificationId, locationId, activity): Reports notification lifecycle activity (e.g., 'notification_delivered', 'cta_engagement', or 'dismissed'). -
submitSurveyResponse(notificationId, locationId, answers): Submits survey answers. Tracks survey or notification lifecycle activity. -
cta(notificationId, locationId):A dedicated helper to track "Call to Action" engagement.
6. Diagnostics and Logging
Utilities to verify bridge health and stream native logs into your React Native UI.
-
getApiKey(): Returns the API key currently active in the native bridge. -
sayHello():Returns a simple string to verify the bridge is connected -
getDeviceLogStreamInfo(): Returns device identity metadata for log-stream targeting. -
getDeviceLogTail(maxLines = 80): Returns latest local log lines. -
startDeviceLogStream(options):Starts periodic log snapshots. ReturnsPromise<BubblDeviceLogStartResult>. -
stopDeviceLogStream(): Stops log stream. -
testNotification(): (iOS Only) Triggers a local test notification to verify UI wiring. On Android this is often unsupported unless a local notification path is wired.
7. Event Subscriptions
Use these methods to listen for data emitted from the native SDKs.
-
onNotification(cb): Subscribes tobubbl_notificationpayloads. -
onGeofence(cb): Subscribes tobubbl_geofencesnapshots. -
onDeviceLog(cb): Subscribes tobubbl_device_logsnapshots.