How to force transition of iMessage Extension view from .expanded to .compact?

1.7k views Asked by At

I have made a simple collection view in the storyboard of iMessage Extension. On selecting an item of the collection , I am creating an MSMessage() object & inserting it in the saved conversation. While this is not an issue while the iMessage view is in .compact mode, there is an issue in .expanded mode. While the MSMessage() object is getting inserted correctly & it's preview being available in the Toolbar accessory of the keyboard, I need to explicitly change the view from .expanded to .compact to see the preview by pressing the arrow button on the top right bar button . Please suggest a way to change the view from .expanded to .compact when I select an item in the collection View programmatically.

1

There are 1 answers

4
jscs On BEST ANSWER

Call requestPresentationStyle(_:) on your MSMessagesAppViewController to make the transition.

Note that the system may not let you do this in certain circumstances, such as immediately upon your app activating. In general you should make the request, as you're planning, only when the user takes an action. From the method's doc:

the user should have ultimate control over the extension’s presentation style.