HtmlMessage

Hierarchy

Index

Constructors

constructor

  • new HtmlMessage(message: string, extras?: Record<string, string>, triggerId?: undefined | string, dismissType?: DismissType, duration?: undefined | number, animateIn?: undefined | false | true, animateOut?: undefined | false | true, frameColor?: undefined | number, htmlId?: undefined | string, css?: undefined | string, messageFields?: Record<string, any>): HtmlMessage
  • An html-content in-app message object which can be passed to showInAppMessage or handled manually. Subscribe to be notified when in-app messages are triggered via subscribeToInAppMessage

    Parameters

    • message: string

      The html content to display to the user.

    • Optional extras: Record<string, string>

      Object of string/string key/value pairs.

    • Optional triggerId: undefined | string

      The id of the trigger that created this message. The SDK will report back this to Braze with in-app message analytics events.

    • Optional dismissType: DismissType

      How the message is dismissed, via a timer or requiring interaction from the user. See the TextAlignment enum.

    • Optional duration: undefined | number

      Length of time in milliseconds until auto-dismiss should occur. Only used when dismissType is DismissType.AUTO_DISMISS.

    • Optional animateIn: undefined | false | true

      Whether to animate the showing of this message.

    • Optional animateOut: undefined | false | true

      Whether to animate the hiding of this message.

    • Optional frameColor: undefined | number

      Color of the background frame which blocks page interaction while the message is showing.

    • Optional htmlId: undefined | string

      The ID to give the parent HTML element that this message is rendered into.

    • Optional css: undefined | string

      Custom CSS to apply to the page while this element is shown. All selectors should be scoped to the htmlId of this message to prevent restyling elements outside of the message when it is shown.

    • Optional messageFields: Record<string, any>

      Structured data provided by the Braze backend.

    Returns HtmlMessage

Properties

animateIn

animateIn: boolean

Whether to animate the showing of this message.

animateOut

animateOut: boolean

Whether to animate the hiding of this message.

Optional css

css: undefined | string

Custom CSS to apply to the page while this element is shown. All selectors should be scoped to the htmlId of this message to prevent restyling elements outside of the message when it is shown.

dismissType

dismissType: DismissType

How the message is dismissed, via a timer or requiring interaction from the user. See the DismissType enum.

duration

duration: number

Length of time in milliseconds until auto-dismiss should occur. Only used when dismissType is DismissType.AUTO_DISMISS

extras

extras: Record<string, string>

Object of string/string key/value pairs.

frameColor

frameColor: number

Color of the background frame which blocks page interaction while the message is showing.

Optional htmlId

htmlId: undefined | string

The ID to give the parent HTML element that this message is rendered into.

isControl

isControl: false

Whether this message is a ControlMessage.

Optional message

message: undefined | string

The message to display to the user.

Optional messageFields

messageFields: Record<string, any>

Structured data provided by the Braze backend.

Optional triggerId

triggerId: undefined | string

The id of the trigger that created this message. The SDK will report back this to Braze with in-app message analytics events.

Static ClickAction

ClickAction: { NEWS_FEED: "NEWS_FEED"; NONE: "NONE"; URI: "URI" }

Type declaration

  • NEWS_FEED: "NEWS_FEED"
  • NONE: "NONE"
  • URI: "URI"

Static CropType

CropType: { CENTER_CROP: "CENTER_CROP"; FIT_CENTER: "FIT_CENTER" }

Type declaration

  • CENTER_CROP: "CENTER_CROP"

    Centers the image in the available space and crops any overflowing edges.

  • FIT_CENTER: "FIT_CENTER"

    Fits the image within the available space, causing blank space on the shorter axis (e.g. tall images will have bars of blank space on the left/right)

Static DismissType

DismissType: { AUTO_DISMISS: "AUTO_DISMISS"; MANUAL: "SWIPE" }

Type declaration

  • AUTO_DISMISS: "AUTO_DISMISS"
  • MANUAL: "SWIPE"

Static ImageStyle

ImageStyle: { GRAPHIC: "GRAPHIC"; TOP: "TOP" }

Type declaration

  • GRAPHIC: "GRAPHIC"
  • TOP: "TOP"

Static OpenTarget

OpenTarget: { BLANK: "BLANK"; NONE: "NONE" }

Type declaration

  • BLANK: "BLANK"
  • NONE: "NONE"

Static Orientation

Orientation: { LANDSCAPE: "LANDSCAPE"; PORTRAIT: "PORTRAIT" }

Type declaration

  • LANDSCAPE: "LANDSCAPE"
  • PORTRAIT: "PORTRAIT"

Static SlideFrom

SlideFrom: { BOTTOM: "BOTTOM"; TOP: "TOP" }

Type declaration

  • BOTTOM: "BOTTOM"
  • TOP: "TOP"

Static TextAlignment

TextAlignment: { CENTER: "CENTER"; END: "END"; START: "START" }

Type declaration

  • CENTER: "CENTER"
  • END: "END"
  • START: "START"

Methods

closeMessage

  • closeMessage(): void
  • Call this method if you wish to programmatically remove the message from the DOM. This method will only work with the Braze UI.

    Returns void

removeAllSubscriptions

  • removeAllSubscriptions(): void

removeSubscription

  • removeSubscription(subscriptionGuid: string): void
  • Remove an event subscription that you previously subscribed to.

    Parameters

    • subscriptionGuid: string

      The identifier of the subscription you wish to remove, returned by the method you initially used to create it.

    Returns void

subscribeToClickedEvent

  • subscribeToClickedEvent(subscriber: () => void): string | null
  • Subscribe to receive click events. The subscriber callback will be called whenever this message is clicked by the user.

    Parameters

    • subscriber: () => void

      The callback function to receive click events. This function will be invoked with no arguments when this message records a click.

        • (): void
        • Returns void

    Returns string | null

    The identifier of the subscription created. This can be passed to removeSubscription to cancel the subscription. Returns null if the subscriber passed is not a function.

subscribeToDismissedEvent

  • subscribeToDismissedEvent(subscriber: () => void): string | null
  • Subscribe to receive dismissed events. The subscriber callback will be called whenever this message is closed by the user, or when it's dismissed automatically (depending on the dismissType).

    Parameters

    • subscriber: () => void

      The callback function to receive dismissed events. This function will be invoked with no arguments when this message records a dismissal.

        • (): void
        • Returns void

    Returns string | null

    The identifier of the subscription created. This can be passed to removeSubscription to cancel the subscription. Returns null if the subscriber passed is not a function.

Static fromJson

  • fromJson(jsonData: Record<string, unknown>): InAppMessage | undefined