BubblMessage
struct · Swiftclass · Kotlintype · TypeScriptclass · DartA 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.
questions) rather than a message.image, video, audio, youtube, application, text or file; null without media.null without media.null if there's none.null without one.Bubbl.openCta); null without one.BubblMessage.fromJson(json: String): BubblMessage?Android onlyjson, 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.
questions) rather than a message.image, video, audio, youtube, application, text or file; nil without media.nil without media.nil if there's none.nil without one.Bubbl.openCta); nil without one.init?(json: String)iOS onlyjson, 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.
questions) rather than a message.image, video, audio, youtube, application, text or file; null without media.null without media.null if there's none.null without one.Bubbl.openCta); null without one.const BubblMessage({required id, required headline, required body, required isSurvey, isSandbox = false, mediaType, mediaUrl, mediaThumbnailUrl, ctaLabel, ctaUrl, questions = const [], required json})Flutter onlyfactory BubblMessage.fromMap(Map<String, Object?> map)Flutter onlyfromJson: 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.
questions) rather than a message.image, video, audio, youtube, application, text or file; null without media.null without media.null if there's none.null without one.Bubbl.openCta); null without one.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).
submitSurvey takes as the answer.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.
Kind because Type is taken in Swift; the property is still type.submitSurvey takes as the answer.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.
submitSurvey takes as the answer.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 is what submitSurvey takes as the answer.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?>.
true or false.answers: [String: Any?].
true or false.answers: Map<String, Object?>.
true or false.answers: SurveyAnswers, which is Record<string, string | string[] | number | boolean | null>.
true or false.