Apple’s new Messages framework for iOS, introduced at WWDC 2016 , aims to make it possible to create app extensions that interact with Apple’s Messages app. The new Messages API enable two kinds of extensions:
- Sticker packs, which provide a collection of images users can include in their messages.
- iMessage apps, which provide access to external apps from within Messages.
Sticker apps do no require any coding and can be created by simply copying image files into a project template provided by Xcode. By contrast, iMessage apps can use the full Messages framework, as explained below. According to Apple, iMessage apps will make it possible to share content, send payments, play games, collaborate, and more, directly from Messages.
The Messages framework includes a number of basic classes that developers can use:
MSMessageAppViewController: this class provides the main view controller for Messages extensions. It allows to present a custom user interface, manage the extension’s state, get the current conversation, track message sending, etc.
MSStickerBrowserViewDataSource: these classes are meant to customize and present a custom or dynamic sticker browser. If you want to provide dynamic content for your sticker browser, you can implement a custom
MSStickerBrowserViewDataSource. If you want to customize the appearance of the default sticker browser, you can provide your own
MSStickerBrowserViewand customize the browser’s size, the size of the stickers, etc. Further customization is possible by subclassing
MSConversation: this class represents a conversation and allows to send text, stickers, attachments, or message objects by inserting them into a message’s input field.
MSMessage: this class allows to create interactive messages and access message properties, such as its sender, the session that the message belongs to, an optional URL associated with it, etc.
MSSession: this class allows to identify messages so they can be later updated, for example, in a game or collaborative app.
The Messages framework is available withXcode 8 beta, which can be freely downloaded by registered developers.