HtmlMessage

Hierarchy

Index

Type aliases

Static ClickAction

ClickAction: "NEWS_FEED" | "URI" | "NONE"

Static CropType

CropType: "CENTER_CROP" | "FIT_CENTER"

Static DismissType

DismissType: "AUTO_DISMISS" | "SWIPE"

Static ImageStyle

ImageStyle: "TOP" | "GRAPHIC"

Static OpenTarget

OpenTarget: "NONE" | "BLANK"

Static Orientation

Orientation: "PORTRAIT" | "LANDSCAPE"

Static SlideFrom

SlideFrom: "TOP" | "BOTTOM"

Static TextAlignment

TextAlignment: "START" | "CENTER" | "END"

Constructors

constructor

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

    Parameters

    • message: string

      The html content to display to the user.

    • Optional extras: Record<string, any>

      Object of string/string key/value pairs.

    • Optional campaignId: string

      If the message comes with a campaign, this is the id of the campaign that the SDK will report back to Appboy with in-app message analytics events.

    • Optional cardId: string

      If the message comes with a card, this is the id of the card that the SDK will report back to Appboy with in-app message analytics events.

    • Optional triggerId: string

      The id of the trigger that created this message. The SDK will report back this to Appboy 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 InAppMessage.TextAlignment enum.

    • Optional duration: number

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

    • Optional animateIn: boolean

      Whether to animate the showing of this message.

    • Optional animateOut: boolean

      Whether to animate the hiding of this message.

    • Optional frameColor: number

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

    • Optional htmlId: string

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

    • Optional css: 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: 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 InAppMessage.DismissType enum.

duration

duration: number

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

extras

extras: Record<string, any>

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: string

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

Optional message

message: string

The message to display to the user.

Optional messageFields

messageFields: Record<string, any>

Structured data provided by the Braze backend.

Optional triggerId

triggerId: string

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

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
  • 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

    The identifier of the subscription created. This can be passed to removeSubscription to cancel the subscription.

subscribeToDismissedEvent

  • subscribeToDismissedEvent(subscriber: () => void): string
  • 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

    The identifier of the subscription created. This can be passed to removeSubscription to cancel the subscription.

Static fromJson

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