ModalMessage

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 ModalMessage(message?: string, messageAlignment?: TextAlignment, extras?: Record<string, any>, campaignId?: string, cardId?: string, triggerId?: string, clickAction?: ClickAction, uri?: string, openTarget?: OpenTarget, dismissType?: DismissType, duration?: number, icon?: string, imageUrl?: string, imageStyle?: ImageStyle, iconColor?: number, iconBackgroundColor?: number, backgroundColor?: number, textColor?: number, closeButtonColor?: number, animateIn?: boolean, animateOut?: boolean, header?: string, headerAlignment?: TextAlignment, headerTextColor?: number, frameColor?: number, buttons?: InAppMessageButton[], cropType?: CropType, htmlId?: string, css?: string): ModalMessage
  • A modal 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

    • Optional message: string

      The message to display to the user.

    • Optional messageAlignment: TextAlignment

      How to align message text. See the InAppMessage.TextAlignment enum.

    • 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 clickAction: ClickAction

      Where the user should be brought when clicking on this message. See the InAppMessage.ClickAction enum.

    • Optional uri: string

      If clickAction is InAppMessage.ClickAction.URI, the URI to follow when the user clicks on this message.

    • Optional openTarget: OpenTarget

      If clickAction is InAppMessage.ClickAction.URI, whether to open clicks in a new tab/window. See the InAppMessage.OpenTarget enum.

    • Optional dismissType: DismissType

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

    • Optional duration: number

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

    • Optional icon: string

      A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See the Font Awesome cheatsheet for details.

    • Optional imageUrl: string

      Url of an image to include in this message. The message will only display an image or an icon, and will prioritize the image if present.

    • Optional imageStyle: ImageStyle

      Whether the image should be shown as normal on the top of the in-app message or used as the entire content of the message. See the InAppMessage.ImageStyle enum.

    • Optional iconColor: number

      Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

    • Optional iconBackgroundColor: number

      Background color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

    • Optional backgroundColor: number

      Background color of entire message. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

    • Optional textColor: number

      Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

    • Optional closeButtonColor: number

      Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

    • Optional animateIn: boolean

      Whether to animate the showing of this message.

    • Optional animateOut: boolean

      Whether to animate the hiding of this message.

    • Optional header: string

      Header text to display.

    • Optional headerAlignment: TextAlignment

      How to align header text. See the InAppMessage.TextAlignment enum.

    • Optional headerTextColor: number

      Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

    • Optional frameColor: number

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

    • Optional buttons: InAppMessageButton[]

      Array of up to twoInAppMessageButton objects.

    • Optional cropType: CropType

      How to crop and fit images in the allowable space. See the InAppMessage.CropType enum.

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

    Returns ModalMessage

Properties

animateIn

animateIn: boolean

Whether to animate the showing of this message.

animateOut

animateOut: boolean

Whether to animate the hiding of this message.

backgroundColor

backgroundColor: number

Background color of entire message. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

buttons

Array of up to twoInAppMessageButton objects.

clickAction

clickAction: ClickAction

Where the user should be brought when clicking on this message. See the InAppMessage.ClickAction enum.

closeButtonColor

closeButtonColor: number

Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

cropType

cropType: CropType

How to crop and fit images in the allowable space. See the InAppMessage.CropType enum.

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 header

header: string

Header text to display.

headerAlignment

headerAlignment: TextAlignment

How to align header text. See the InAppMessage.TextAlignment enum.

headerTextColor

headerTextColor: number

Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

Optional htmlId

htmlId: string

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

Optional icon

icon: string

A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See the Font Awesome cheatsheet for details.

iconBackgroundColor

iconBackgroundColor: number

Background color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

iconColor

iconColor: number

Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

imageStyle

imageStyle: ImageStyle

Whether the image should be shown as normal on the top of the in-app message or used as the entire content of the message. See the InAppMessage.ImageStyle enum.

Optional imageUrl

imageUrl: string

Url of an image to include in this message. The message will only display an image or an icon, and will prioritize the image if present.

Optional message

message: string

The message to display to the user.

messageAlignment

messageAlignment: TextAlignment

How to align message text. See the InAppMessage.TextAlignment enum.

openTarget

openTarget: OpenTarget

If clickAction is InAppMessage.ClickAction.URI, whether to open clicks in a new tab/window. See the InAppMessage.OpenTarget enum.

textColor

textColor: number

Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque green).

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.

Optional uri

uri: string

If clickAction is InAppMessage.ClickAction.URI, the URI to follow when the user clicks on this message.

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