InAppMessage
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
InAppMessage is a data class in the Salesforce Marketing Cloud Unified SDK that represents an in-app message configuration. It implements the Android Parcelable interface for efficient serialization.
Package: com.salesforce.marketingcloud.inappmessaging.models
Module: inappmessagingmodelsmodule
Version: 1.0.0
SDK Version: 11.0
1data class InAppMessage(
2 // constructor parameters listed below
3) : Parcelable| Parameter | Type | Default Value | Description |
|---|---|---|---|
id | String | - | Message identifier |
priority | Int | 999 | Message priority for display ordering |
startDateUtc | Date? | null | Message start date in UTC |
endDateUtc | Date? | null | Message end date in UTC |
modifiedDateUtc | Date? | null | Last modification date in UTC |
displayLimit | Int | 1 | Maximum number of times the message can be displayed |
displayCount | Int | 0 | Current count of how many times the message has been displayed |
type | InAppMessage.Type | - | Message type (modal, banner, fullscreen, etc.) |
windowColor | String? | null | Window background color |
displayDuration | Long | -1 | Display duration in milliseconds (-1 for indefinite) |
backgroundColor | String? | - | Message background color |
cornerRadius | InAppMessage.Size | Size.s | Corner radius size |
layoutOrder | InAppMessage.LayoutOrder | LayoutOrder.ImageTitleBody | Component layout order |
media | InAppMessage.Media? | null | Media configuration (image/video) |
title | InAppMessage.TextField? | null | Title text field configuration |
body | InAppMessage.TextField? | null | Body text field configuration |
tertiaryText | InAppMessage.TertiaryTextField? | null | Tertiary text field with hyperlink support |
closeButton | InAppMessage.CloseButton? | null | Close button configuration |
buttonConfiguration | InAppMessage.ButtonConfig | ButtonConfig.twoUp | Button layout configuration |
buttons | List<InAppMessage.Button>? | null | List of action buttons |
messageDelaySec | Int | 0 | Delay before displaying the message in seconds |
displaySuppressionAction | List<String>? | null | List of actions that suppress message display |
shadow | InAppMessage.Shadow? | null | Shadow effect configuration |
additionalMargin | InAppMessage.Margin? | null | Additional margin spacing |
animation | InAppMessage.Animation? | null | Animation configuration |
border | InAppMessage.Border? | null | Border configuration |
appLimitOverride | Boolean | false | Override app-level display limits |
source | Event.Producer | - | Event producer source |
All constructor parameters are exposed as public properties with the @JvmField annotation, making them directly accessible from both Kotlin and Java code.
1fun component1(): String // id
2fun component2(): Int // priority
3// ... through component28Component functions for destructuring the data class.
1fun copy(
2 id: String = this.id,
3 priority: Int = this.priority,
4 // ... all other parameters with defaults
5): InAppMessageCreates a copy of the instance with optional parameter modifications.
1fun equals(other: Any?): BooleanCompares this instance with another object for equality.
1fun hashCode(): IntReturns a hash code value for the object.
1fun toString(): StringReturns a string representation of the object.
1fun describeContents(): IntDescribe the kinds of special objects contained in this Parcelable instance.
1fun writeToParcel(parcel: Parcel, flags: Int): UnitFlatten this object into a Parcel.
1companion object {
2 val CREATOR: Parcelable.Creator<InAppMessage>
3}Used by the Android framework for parceling and unparceling InAppMessage instances.
Defines component alignment options.
Values:
start - Align to the startcenter - Align to the centerend - Align to the endDefines button layout configurations.
Values:
twoUp - Two-button layout (default)Defines media content scaling modes.
Values:
fill - Fill the container (default)fit - Fit within the containerDefines the order of message components.
Values:
ImageTitleBody - Image, then title, then body (default)Predefined size values for various styling properties.
Values:
xs - Extra smalls - Small (commonly used default)m - Mediuml - Largexl - Extra largexxl - Extra extra largee2e - Edge-to-edge (used in Media.ImageSize)Text alignment options.
Values:
left - Left-alignedcenter - Center-aligned (default)right - Right-alignedMessage type variants.
Values:
modal - Modal dialog messagebanner - Banner messagefullscreen - Fullscreen messageAnimation settings for the in-app message.
1data class Animation(
2 val type: AnimationType? = null, // Animation style
3 val duration: Int = 450 // Animation duration in milliseconds
4) : ParcelableBorder styling configuration.
1data class Border(
2 val width: Size = Size.s, // Border width
3 val color: String? = null // Border color (hex or named)
4) : ParcelableAction button configuration.
1data class Button(
2 val id: String, // Button identifier
3 val index: Int = 0, // Button index for ordering
4 val text: String, // Button text
5 val actionType: ActionType = ActionType.close, // Action type
6 val action: String? = null, // Action value/URL
7 val backgroundColor: String? = null, // Background color
8 val cornerRadius: Size = Size.s, // Corner radius
9 val font: Font? = null, // Font configuration
10 val border: Border? = null, // Border configuration
11 val margin: Margin? = null, // Margin spacing
12 val additionalMargin: Margin? = null, // Additional margin
13 val textAlignment: TextAlignment = TextAlignment.center, // Text alignment
14 val shadow: Shadow? = null // Shadow effect
15) : ParcelableClose button configuration.
1data class CloseButton(
2 val alignment: Alignment = Alignment.end, // Button alignment
3 val iconColor: String? = null, // Icon color
4 val backgroundColor: String? = null, // Background color
5 val additionalMargin: Margin? = null // Additional margin
6) : ParcelableFont configuration.
1data class Font(
2 val size: Size = Size.s, // Font size
3 val color: String? = null, // Font color
4 val style: FontStyle? = null, // Font style (bold, italic, etc.)
5 val fontFamily: String? = null // Font family name
6) : ParcelableSpacing configuration for all sides.
1data class Margin(
2 val top: Size? = null, // Top margin
3 val bottom: Size? = null, // Bottom margin
4 val left: Size? = null, // Left margin
5 val right: Size? = null // Right margin
6) : ParcelableImage or video media configuration.
1data class Media(
2 val url: String, // Media URL
3 val altText: String? = null, // Accessibility alt text
4 val size: ImageSize = ImageSize.e2e, // Image size
5 val cornerRadius: Size = Size.s, // Corner radius
6 val altMedia: String? = null, // Alternative media URL
7 val insetSize: Size? = null, // Inset size
8 val border: Border? = null, // Border configuration
9 val shadow: Shadow? = null, // Shadow effect
10 val margin: Margin? = null, // Margin spacing
11 val additionalMargin: Margin? = null, // Additional margin
12 val aspectRatio: String = DEFAULT_ASPECT_RATIO, // Aspect ratio
13 val contentMode: ContentMode = ContentMode.fill // Content scaling mode
14) : ParcelableShadow effect configuration.
1data class Shadow(
2 val length: Size? = null, // Shadow length/blur radius
3 val color: String? = null // Shadow color
4) : ParcelableBasic text field configuration.
1data class TextField(
2 val text: String, // Text content
3 val alignment: Alignment = Alignment.center, // Text alignment
4 val font: Font? = null, // Font configuration
5 val margin: Margin? = null, // Margin spacing
6 val additionalMargin: Margin? = null // Additional margin
7) : ParcelableText field with hyperlink support, extends TextField functionality.
1data class TertiaryTextField(
2 val text: String, // Text content
3 val alignment: Alignment = Alignment.center, // Text alignment
4 val font: Font? = null, // Font configuration
5 val margin: Margin? = null, // Margin spacing
6 val additionalMargin: Margin? = null, // Additional margin
7 val hyperlinks: List<String>? = null, // List of hyperlink URLs
8 val linkColor: String? = null // Hyperlink color
9) : Parcelable1// Create a simple modal in-app message
2val message = InAppMessage(
3 id = "msg_12345",
4 type = InAppMessage.Type.modal,
5 backgroundColor = "#FFFFFF",
6 title = InAppMessage.TextField(
7 text = "Welcome!",
8 font = InAppMessage.Font(
9 size = InAppMessage.Size.l,
10 color = "#000000"
11 )
12 ),
13 body = InAppMessage.TextField(
14 text = "Thanks for using our app!",
15 font = InAppMessage.Font(
16 size = InAppMessage.Size.m,
17 color = "#333333"
18 )
19 ),
20 buttons = listOf(
21 InAppMessage.Button(
22 id = "btn_1",
23 text = "Got it!",
24 actionType = ActionType.close,
25 backgroundColor = "#007AFF"
26 )
27 ),
28 closeButton = InAppMessage.CloseButton(
29 alignment = InAppMessage.Alignment.end,
30 iconColor = "#666666"
31 ),
32 source = Event.Producer.SFMC
33)@JvmField annotation for direct Java interoperabilityParcelable for efficient passing between Android components