InAppMessage

Overview 

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

Class Declaration 

1data class InAppMessage(
2    // constructor parameters listed below
3) : Parcelable

Constructor 

Parameters 

ParameterTypeDefault ValueDescription
idString-Message identifier
priorityInt999Message priority for display ordering
startDateUtcDate?nullMessage start date in UTC
endDateUtcDate?nullMessage end date in UTC
modifiedDateUtcDate?nullLast modification date in UTC
displayLimitInt1Maximum number of times the message can be displayed
displayCountInt0Current count of how many times the message has been displayed
typeInAppMessage.Type-Message type (modal, banner, fullscreen, etc.)
windowColorString?nullWindow background color
displayDurationLong-1Display duration in milliseconds (-1 for indefinite)
backgroundColorString?-Message background color
cornerRadiusInAppMessage.SizeSize.sCorner radius size
layoutOrderInAppMessage.LayoutOrderLayoutOrder.ImageTitleBodyComponent layout order
mediaInAppMessage.Media?nullMedia configuration (image/video)
titleInAppMessage.TextField?nullTitle text field configuration
bodyInAppMessage.TextField?nullBody text field configuration
tertiaryTextInAppMessage.TertiaryTextField?nullTertiary text field with hyperlink support
closeButtonInAppMessage.CloseButton?nullClose button configuration
buttonConfigurationInAppMessage.ButtonConfigButtonConfig.twoUpButton layout configuration
buttonsList<InAppMessage.Button>?nullList of action buttons
messageDelaySecInt0Delay before displaying the message in seconds
displaySuppressionActionList<String>?nullList of actions that suppress message display
shadowInAppMessage.Shadow?nullShadow effect configuration
additionalMarginInAppMessage.Margin?nullAdditional margin spacing
animationInAppMessage.Animation?nullAnimation configuration
borderInAppMessage.Border?nullBorder configuration
appLimitOverrideBooleanfalseOverride app-level display limits
sourceEvent.Producer-Event producer source

Properties 

All constructor parameters are exposed as public properties with the @JvmField annotation, making them directly accessible from both Kotlin and Java code.

Methods 

Data Class Methods 

component1() through component28() 

1fun component1(): String  // id
2fun component2(): Int     // priority
3// ... through component28

Component functions for destructuring the data class.

copy() 

1fun copy(
2    id: String = this.id,
3    priority: Int = this.priority,
4    // ... all other parameters with defaults
5): InAppMessage

Creates a copy of the instance with optional parameter modifications.

equals() 

1fun equals(other: Any?): Boolean

Compares this instance with another object for equality.

hashCode() 

1fun hashCode(): Int

Returns a hash code value for the object.

toString() 

1fun toString(): String

Returns a string representation of the object.

Parcelable Methods 

describeContents() 

1fun describeContents(): Int

Describe the kinds of special objects contained in this Parcelable instance.

writeToParcel() 

1fun writeToParcel(parcel: Parcel, flags: Int): Unit

Flatten this object into a Parcel.

Companion Object 

CREATOR 

1companion object {
2    val CREATOR: Parcelable.Creator<InAppMessage>
3}

Used by the Android framework for parceling and unparceling InAppMessage instances.

Nested Types 

Enums 

Alignment 

Defines component alignment options.

Values:

  • start - Align to the start
  • center - Align to the center
  • end - Align to the end

ButtonConfig 

Defines button layout configurations.

Values:

  • twoUp - Two-button layout (default)
  • Additional values may be available

ContentMode 

Defines media content scaling modes.

Values:

  • fill - Fill the container (default)
  • fit - Fit within the container
  • Additional values may be available

LayoutOrder 

Defines the order of message components.

Values:

  • ImageTitleBody - Image, then title, then body (default)
  • Additional values may be available

Size 

Predefined size values for various styling properties.

Values:

  • xs - Extra small
  • s - Small (commonly used default)
  • m - Medium
  • l - Large
  • xl - Extra large
  • xxl - Extra extra large
  • e2e - Edge-to-edge (used in Media.ImageSize)

TextAlignment 

Text alignment options.

Values:

  • left - Left-aligned
  • center - Center-aligned (default)
  • right - Right-aligned

Type 

Message type variants.

Values:

  • modal - Modal dialog message
  • banner - Banner message
  • fullscreen - Fullscreen message
  • Additional values may be available

Data Classes 

Animation 

Animation 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) : Parcelable

Border 

Border styling configuration.

1data class Border(
2    val width: Size = Size.s,     // Border width
3    val color: String? = null     // Border color (hex or named)
4) : Parcelable

Button 

Action 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) : Parcelable

CloseButton 

Close 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) : Parcelable

Font 

Font 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) : Parcelable

Margin 

Spacing 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) : Parcelable

Media 

Image 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) : Parcelable

Shadow 

Shadow effect configuration.

1data class Shadow(
2    val length: Size? = null,    // Shadow length/blur radius
3    val color: String? = null    // Shadow color
4) : Parcelable

TextField 

Basic 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) : Parcelable

TertiaryTextField 

Text 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) : Parcelable

Usage Example 

1// 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)

Notes 

  • All properties use @JvmField annotation for direct Java interoperability
  • Color values can be specified as hex strings (e.g., “#FFFFFF”) or named colors
  • Nullable properties allow for flexible configuration
  • Default values are provided for most styling properties
  • The class implements Parcelable for efficient passing between Android components
  • Complete enum value lists may vary; refer to source code for exhaustive options