Framework

Messages

Create app extensions that interact with the Messages app, allowing users to send text, stickers, media files, and interactive messages. Update interactive messages, adjusting the state of each message as the conversation’s participants interact with it.

Overview

You can use the Messages framework to create two types of app extensions: Sticker packs and iMessage apps. Both extension types can be created as standalone apps or as app extensions within a containing iOS app.

For more information on creating and working with app extensions, see App Extension Programming Guide.

Sticker Packs

Sticker packs simply provide static sets of stickers, images that users can send inline as messages or peel off and attach to message bubbles in the transcript. Sticker packs do not require any code. You add stickers by dragging image files into the Sticker Pack folder inside the Stickers asset catalog. Valid image files must meet the following specifications:

  • The image must be a PNG, APNG, GIF, or JPEG file.

  • The file must be less than 500 KB.

  • For the best results, the image should not be smaller than 100 x 100 points or larger than 206 x 206 points.

Messages supports three sticker sizes, which are displayed in a grid-based browser. In the Xcode Attributes inspector, pick one of the following sizes for your sticker pack:

  • Small. 100 x 100 points @3x (300 x 300 pixels).

  • Medium. 136 x 136 points @3x (408 x 408 pixels).

  • Large. 206 x 206 points @3x (618 x 618 pixels).

For optimal quality and performance, provide sticker images of the size you choose.

To learn more about creating animated stickers, see Creating Stickers with Motion.

To learn more about submitting sticker packs to the App Store, see Preparing Sticker Submissions.

iMessage Apps

iMessage apps leverage the full framework to interact with the Messages app.

Use iMessage apps to:

To learn more about submitting iMessage Apps to the App Store, see Preparing Your iMessage App for Submission.

Topics

Classes

MSConversation

The MSConversation class represents a conversation in the Messages app. Use conversation objects to access information about the currently selected message or the conversation participants, or to send text, stickers, attachments, or message objects.

MSMessage

Use the MSMessage class to create interactive message objects. To create a message that can be updated by the conversation’s participants, instantiate a message with a session using the initWithSession: method. Otherwise, instantiate the message using the init method.

MSMessageLayout

The MSMessageLayout class is an abstract base class that defines the appearance of MSMessage objects in the conversation transcript.

MSMessageLiveLayout

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

MSMessagesAppViewController

The MSMessagesAppViewController class acts as the principal view controller for Messages extensions. Use this class to manage your extension. For more information on app extensions, see App Extension Programming Guide.

MSMessageTemplateLayout

The MSMessageTemplateLayout describes how an MSMessage object is presented in the transcript. The message template includes the Message extension’s icon, an image, video, or audio file, and a number of text elements (title, subtitle, caption, subcaption, trailing caption, and trailing subcaption). These elements are laid out as shown in Figure 1.

MSSession

Use the MSSession class to create and update messages.

MSSticker

A sticker for use in the Messages app. A sticker can be sent as a new message or attached to an existing balloon in the transcript.

MSStickerBrowserView

Use the MSStickerBrowserView class to display a dynamically generated list of stickers. The browser provides drag-and-drop functionality. The user can press and hold a sticker to peel it from the browser, then drag the sticker to any balloon in the transcript. The user can also tap stickers to add them to the Messages app’s input field.

MSStickerBrowserViewController

Use the MSStickerBrowserViewController to present the standard sticker browser. This browser provides drag-and-drop functionality. The user can press and hold a sticker to peel it from the browser, then drag the sticker to any balloon in the transcript. The user can also tap stickers to add them to the Messages app’s input field.

MSStickerView

Use the MSStickerView class to display sticker objects. The sticker view also provides drag-and-drop functionality. The user can press and hold a sticker to peel it from the view, and then drag the sticker to any balloon in the transcript.

Protocols

MSStickerBrowserViewDataSource

Implement the MSStickerBrowserViewDataSource protocol to dynamically provide stickers for a browser.

MSMessagesAppTranscriptPresentation

A protocol that provides support for displaying live messages in the transcript of the Messages app.

Reference

Errors

This document describes the error domains and codes used in sticker packs and iMessage apps.