ChangelogEdit pageSTAFFOpen dashboard

BubblMessage

struct · Swiftclass · Kotlintype · TypeScriptclass · Dart

A notification from Bubbl as your app sees it, with its survey questions and the answer each question takes.

Your app gets a BubblMessage from the notification listener and from notification events. It has enough to draw the notification yourself, or to hand it back to Bubbl.present to show Bubbl's screen. Report what the user does with the report functions and submitSurvey on Bubbl. More in Drawing notifications yourself and Notifications and surveys.

BubblMessage#

The same fields on every platform. json is the whole notification as the device API sent it: keep it for an in-app inbox, and turn it back into a message to show again with Bubbl.present.

class BubblMessage. Apps get it from Bubbl; its constructor is internal. toString() gives the id and headline.

id
String
The notification's id. Echo it on anything your app reports about it.
headline
String
The title.
body
String
The text.
isSurvey
Boolean
A survey (questions) rather than a message.
isSandbox
Boolean
From a Sandbox workspace. An app drawing its own UI should mark it; Bubbl's screen shows a SANDBOX ribbon.
mediaType
String?
image, video, audio, youtube, application, text or file; null without media.
mediaUrl
String?
The media's URL; null without media.
mediaThumbnailUrl
String?
A still image for the media; null if there's none.
ctaLabel
String?
The call-to-action button's label; null without one.
ctaUrl
String?
Where the call to action goes (Bubbl.openCta); null without one.
questions
List<BubblQuestion>
A survey's questions in order; empty for a message.
json
String
The whole notification as the device API sent it (JSON).
BubblMessage.fromJson(json: String): BubblMessage?Android only
A message back from its json, for example one kept for an inbox; null if it isn't one. @JvmStatic on the companion.

The notification listener implements fun interface BubblNotificationListener { fun onNotification(message: BubblMessage): Boolean }: return true when the app shows message itself.

public struct BubblMessage: Sendable, Hashable, CustomStringConvertible. Apps get it from Bubbl, or rebuild it from json.

id
String
The notification's id. Echo it on anything your app reports about it.
headline
String
The title.
body
String
The text.
isSurvey
Bool
A survey (questions) rather than a message.
isSandbox
Bool
From a Sandbox workspace. An app drawing it itself should mark it, as Bubbl's screen does with its SANDBOX ribbon.
mediaType
String?
image, video, audio, youtube, application, text or file; nil without media.
mediaUrl
String?
The media's URL; nil without media.
mediaThumbnailUrl
String?
A still image for the media; nil if there's none.
ctaLabel
String?
The call-to-action button's label; nil without one.
ctaUrl
String?
Where the call to action goes (Bubbl.openCta); nil without one.
questions
[BubblQuestion]
A survey's questions in order; empty for a message.
json
String
The whole notification as the device API sent it (JSON).
description
String
The id and headline, for logs.
init?(json: String)iOS only
A message back from its json, for example one kept for an inbox; nil when it isn't one.

class BubblMessage. The fields are worked out by the native SDK; only json goes back to it.

id
String
The notification's id. Echo it on anything your app reports about it.
headline
String
The title.
body
String
The text.
isSurvey
bool
A survey (questions) rather than a message.
isSandbox
bool
From a Sandbox workspace; Bubbl marks its own screen as such.
mediaType
String?
image, video, audio, youtube, application, text or file; null without media.
mediaUrl
String?
The media's URL; null without media.
mediaThumbnailUrl
String?
A still image for the media (a video's poster, say); null if there's none.
ctaLabel
String?
The call-to-action button's label; null without one.
ctaUrl
String?
Where the call to action goes (Bubbl.openCta); null without one.
questions
List<BubblQuestion>
A survey's questions in order; empty for a message.
json
String
The whole notification as the device API sent it (JSON).
const BubblMessage({required id, required headline, required body, required isSurvey, isSandbox = false, mediaType, mediaUrl, mediaThumbnailUrl, ctaLabel, ctaUrl, questions = const [], required json})Flutter only
A message with its fields. Apps get these from Bubbl rather than making them.
factory BubblMessage.fromMap(Map<String, Object?> map)Flutter only
From the message object the native SDK sends.
Keeping messages for an inboxFlutter has no counterpart of the native fromJson: the native SDK reads only json from a message you pass back, so keep the fields you need along with it.

type BubblMessage, a plain object filled in natively. Only json goes back to the native SDK.

id
string
The notification's id. Echo it on anything reported about it.
headline
string
The title.
body
string
The text.
isSurvey
boolean
A survey (questions) rather than a message.
isSandbox
boolean
Sent from a Sandbox workspace.
mediaType
string | null
image, video, audio, youtube, application, text or file; null without media.
mediaUrl
string | null
The media's URL; null without media.
mediaThumbnailUrl
string | null
A still image for the media; null if there's none.
ctaLabel
string | null
The call-to-action button's label; null without one.
ctaUrl
string | null
Where the call to action goes (Bubbl.openCta); null without one.
questions
BubblQuestion[]
A survey's questions in order; empty for a message.
json
string
The whole notification as the device API sent it (JSON). Keep it to show the message again later with present().

BubblQuestion#

One question of a survey. Its id is the key for its answer in submitSurvey.

data class BubblQuestion(id, text, type, required, choices).

id
String
The question's id: the key for its answer.
text
String
The question as the user reads it.
type
BubblQuestion.Type
What kind of answer it takes.
required
Boolean
Whether it must be answered.
choices
List<BubblQuestion.Choice>
The choices, for single and multiple choice.
Choice.id
String
The choice's id: what submitSurvey takes as the answer.
Choice.text
String
The choice as the user reads it.

enum class BubblQuestion.Type: OPEN_ENDED, SINGLE_CHOICE, MULTIPLE_CHOICE, RATING, BOOLEAN, NUMBER, SLIDER.

public struct BubblQuestion: Sendable, Hashable. Apps get it from Bubbl; it has no public initializer.

id
String
The question's id: the key for its answer.
text
String
The question as the user reads it.
type
BubblQuestion.Kind
What kind of answer it takes. The type is named Kind because Type is taken in Swift; the property is still type.
required
Bool
Whether it must be answered.
choices
[BubblQuestion.Choice]
The choices, for single and multiple choice.
Choice.id
String
The choice's id: what submitSurvey takes as the answer.
Choice.text
String
The choice as the user reads it.

enum BubblQuestion.Kind: String, Sendable, CaseIterable: .openEnded ("open_ended"), .singleChoice ("single_choice"), .multipleChoice ("multiple_choice"), .rating, .boolean, .number, .slider.

class BubblQuestion, with a const constructor and a BubblQuestion.fromMap(Map<String, Object?> map) factory.

id
String
The question's id: the key for its answer.
text
String
The question as the user reads it.
type
BubblQuestionType
What kind of answer it takes.
required
bool
Whether it must be answered.
choices
List<BubblChoice>
The choices, for single and multiple choice.
BubblChoice.id
String
The choice's id: what submitSurvey takes as the answer.
BubblChoice.text
String
The choice as the user reads it.

enum BubblQuestionType: openEnded, singleChoice, multipleChoice, rating, boolean, number, slider. BubblChoice is a class of its own, with a const constructor and a fromMap factory.

type BubblQuestion.

id
string
The question's id: the key for its answer.
text
string
The question as the user reads it.
type
QuestionType
What kind of answer it takes.
required
boolean
Whether it must be answered.
choices
{ id: string; text: string }[]
The choices, for single and multiple choice. A choice's id is what submitSurvey takes as the answer.
QuestionType
'openEnded' | 'singleChoice' | 'multipleChoice' | 'rating' | 'boolean' | 'number' | 'slider'
The question types.

Survey answers#

submitSurvey takes the answers by question id and checks them as the server does. It returns false, and logs why, when they can't be sent:

  • an id that isn't a question of this survey;
  • an answer of the wrong kind for its question;
  • a required question with no answer.

A null answer counts as no answer. The answer each question type takes:

answers: Map<String, Any?>.

SINGLE_CHOICE
String
One of its choice ids.
MULTIPLE_CHOICE
List<String>
A list of its choice ids.
RATING
Int
A whole number from 1 to 5.
BOOLEAN
Boolean
true or false.
NUMBER
Int or Double
Any finite number.
SLIDER
Double
A number from 0 to 10.
OPEN_ENDED
String
Text of at most 2000 characters.

answers: [String: Any?].

.singleChoice
String
One of its choice ids.
.multipleChoice
[String]
A list of its choice ids.
.rating
Int
A whole number from 1 to 5.
.boolean
Bool
true or false.
.number
Int or Double
Any finite number.
.slider
Double
A number from 0 to 10.
.openEnded
String
Text of at most 2000 characters.

answers: Map<String, Object?>.

singleChoice
String
One of its choice ids.
multipleChoice
List<String>
A list of its choice ids.
rating
int
A whole number from 1 to 5.
boolean
bool
true or false.
number
num
Any finite number.
slider
num
A number from 0 to 10.
openEnded
String
Text of at most 2000 characters.

answers: SurveyAnswers, which is Record<string, string | string[] | number | boolean | null>.

'singleChoice'
string
One of its choice ids.
'multipleChoice'
string[]
A list of its choice ids.
'rating'
number
A whole number from 1 to 5.
'boolean'
boolean
true or false.
'number'
number
Any finite number.
'slider'
number
A number from 0 to 10.
'openEnded'
string
Text of at most 2000 characters.