<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Messages",
  "identifier" : "/documentation/Messages/MSMessageLiveLayout",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Messages"
    ],
    "preciseIdentifier" : "c:objc(cs)MSMessageLiveLayout"
  },
  "title" : "MSMessageLiveLayout"
}
-->

# MSMessageLiveLayout

A layout that provides a custom, interactive view inside the transcript.

```
class MSMessageLiveLayout
```

## Overview

Use a live layout instance to create custom, interactive messages in the transcript (or input field). An alternative layout is required to represent your message on devices that don’t have your iMessage app installed, or on devices that aren’t running iOS 11 or later. Note: this could be either the receiver’s or the sender’s device; the sender may have a second device that doesn’t have your app installed.

Set the alternative layout when you instantiate your [`MSMessageLiveLayout`](/documentation/Messages/MSMessageLiveLayout) object. Use an [`MSMessageTemplateLayout`](/documentation/Messages/MSMessageTemplateLayout) instance. The template layout automatically provides support for devices that do not support iMessage apps (macOS, iOS 9 and earlier, and SMS devices). See below for an example.

Listing 1. Sending a live message.

```swift
let alternateMessageLayout = MSMessageTemplateLayout()
// Configure the template layout here...


let messageLayout = MSMessageLiveLayout(alternateLayout: alternateMessageLayout)

let message = MSMessage()
message.layout = messageLayout

conversation.send(message) { (errorOrNil) in
    if let error = errorOrNil {
        // Handle the error here...
    }
}
```

When an [`MSMessage`](/documentation/Messages/MSMessage) object with a live layout is added to the transcript (or input field), the system instantiates a new instance of your [`MSMessagesAppViewController`](/documentation/Messages/MSMessagesAppViewController) subclass, with its [`presentationStyle`](/documentation/Messages/MSMessagesAppViewController/presentationStyle) property set to the [`MSMessagesAppPresentationStyle.transcript`](/documentation/Messages/MSMessagesAppPresentationStyle/transcript) value.

The view controller’s [`selectedMessage`](/documentation/Messages/MSConversation/selectedMessage) property is set to the interactive message just before the controller’s [`willBecomeActive(with:)`](/documentation/Messages/MSMessagesAppViewController/willBecomeActive(with:)) method is called. Use the [`selectedMessage`](/documentation/Messages/MSConversation/selectedMessage) property to access the message and display its contents.

The Messages app renders your controller’s view inside a bubble in the transcript.  Your controller must check its presentation style and display an appropriate user interface for the message. You can define the message’s size by overriding your view controller’s [`contentSizeThatFits(_:)`](/documentation/Messages/MSMessagesAppTranscriptPresentation/contentSizeThatFits(_:)) method.

There can be multiple live messages (from multiple iMessage apps) in the transcript at the same time. This means your app may have multiple instances of its [`MSMessagesAppViewController`](/documentation/Messages/MSMessagesAppViewController) subclass running concurrently:

- One instance for each message in the transcript
- One instance for a message in the input field (when you stage the message by calling [`insert(_:completionHandler:)`](/documentation/Messages/MSConversation/insert(_:completionHandler:)-3g248))
- One instance for the app’s main interface if your iMessage app is currently active

## Topics

### Creating Live Layouts

[`init(alternateLayout:)`](/documentation/Messages/MSMessageLiveLayout/init(alternateLayout:))

Initializes a new live layout using the provided alternate layout.

### Accessing Properties

[`alternateLayout`](/documentation/Messages/MSMessageLiveLayout/alternateLayout)

A template layout to be displayed when the live layout is unavailable.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)