Bubbl for a Flutter app: the same functions as the native SDKs (docs/PUBLIC_API.md), in Dart. A thin bridge: everything (geofences, notifications, the queue, consent) runs in the native SDK, which keeps working with the app closed; Dart only calls it and hears from it.
Install: add the package, then in main():
await Bubbl.start(apiKey: 'pk_live_…', options: const BubblOptions(baseUrl: 'https://…'));
Calls before start do nothing, and a mistake (an empty key, an http:// URL) is logged natively, never thrown, as the native SDKs do.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
events
→ Stream<
BubblEvent> -
What Bubbl does as it happens (BubblEvent).
no setter
-
isSupported
→ Future<
bool> -
Whether Bubbl works on this device: Android 8.1 (API 27) or iOS 17 and later. The plugin
installs on older versions (Android 6, iOS 13) and there every call does nothing, safely.
no setter
Static Methods
-
addEventListener(
void listener(BubblEvent event)) → StreamSubscription< BubblEvent> -
listeneris told of each BubblEvent; pass the result to removeEventListener to stop. -
deleteMyData(
) → Future< void> - Erase this device and everything Bubbl recorded about it, on the server and here. Bubbl stays off afterwards; a later setConsent(true) starts afresh as a new device.
-
diagnostics(
) → Future< BubblDiagnostics> - Where Bubbl stands on this device, for support and for an app's own debug screen.
-
isBubblMessage(
Map< String, Object?> data) → bool -
Whether a push's
datais Bubbl's (Bubbl handles its own pushes; the app's handler can skip these). -
openCta(
BubblMessage message) → Future< void> -
Open
message's call to action the way Bubbl's screen would, and report the click. -
optOut(
) → Future< void> - Stop Bubbl for this user: nothing more is sent, shown or tracked, and the server is told.
-
present(
BubblMessage message) → Future< void> -
Show
messagein Bubbl's notification screen (e.g. one the listener held back, or one kept in the app's inbox). -
registerTestDevice(
String code) → Future< BubblTestDeviceResult> - Approves this device as a test device in its Sandbox (a pk_test_ key) with a code from the dashboard, so it gets that Sandbox's notifications. Not approved: BubblTestDeviceResult.message says why. Never throws.
-
removeEventListener(
StreamSubscription< BubblEvent> subscription) → Future<void> - Stops a listener addEventListener returned.
-
reportCtaClicked(
BubblMessage message) → Future< void> - …the user tapped its call to action.
-
reportDismissed(
BubblMessage message) → Future< void> - …the user closed it without acting.
-
reportDisplayed(
BubblMessage message) → Future< void> - For an app drawing notifications itself: it's on screen.
-
reportMediaCompleted(
BubblMessage message, double durationSeconds) → Future< void> -
…its video or audio played to the end,
durationSecondslong. -
reportMediaViewed(
BubblMessage message) → Future< void> - …its media (video, audio, a YouTube video, an image) was shown or started playing.
-
reportOpened(
BubblMessage message) → Future< void> - …the user opened it (tapped it, rather than it opening on its own).
-
reportSurveyStarted(
BubblMessage message) → Future< void> - …the user started answering its survey.
-
setConsent(
bool granted) → Future< void> - The user's answer, for apps started with requireConsent: true starts everything, false is the same as optOut.
-
setLocationEnabled(
bool enabled) → Future< void> - Turn Bubbl's use of location (geofences) off or on again; the rest carries on.
-
setNotificationListener(
FutureOr< bool> listener(BubblMessage message)?) → Future<void> - The app's say over each notification before Bubbl shows it, while the app is on screen: return true to show it yourself (then report what happens with reportDisplayed and the others), false to let Bubbl show it. Null goes back to Bubbl showing everything.
-
setSegments(
List< String> segments) → Future<void> - The device's segments, for targeting campaigns (replaces any set before).
-
start(
{required String apiKey, required BubblOptions options}) → Future< void> - Start Bubbl. Call once per launch, early; the same key and options again change nothing. When the OS wakes the app for a geofence or a push, the native SDK starts itself from what it saved, before any Dart runs.
-
startWithCredential(
BubblCredential credential, {required BubblOptions options}) → Future< void> - Start Bubbl with a device credential issued outside the app instead of an API key: the device never registers itself. As start otherwise, and called the same way at every launch. A different credential than last time, or switching from an API key, starts afresh as a new device. If the server refuses it, Bubbl stops (BubblCredentialRejected, BubblDiagnostics.credentialRejected) until it's started with a new one.
-
stop(
) → Future< void> - Stop Bubbl on this device until start again: nothing more runs, nothing is dropped, and the server isn't told (unlike optOut).
-
submitSurvey(
BubblMessage message, Map< String, Object?> answers) → Future<bool> -
Send the answers to a survey the app showed itself:
answersby question id, as each BubblQuestion says. Checked as the server checks them; false (and a warning logged, with why) when they can't be sent, e.g. a required question unanswered or a rating of 6. -
track(
String name, [Map< String, Object?> properties = const <String, Object?>{}]) → Future<void> -
An event of the app's own, for reports: a
nameof letters, digits and . _ : - (at most 100), and up to 50 flatproperties(text, numbers, true/false or null).
Constants
- permissions → const BubblPermissions
- The permissions Bubbl uses: their state, and asking for them (the privacy view first when the dashboard says so, then the system prompt).