Tom Coomer
Tom Coomer

Reputation: 6567

Disable iMessage App Resizing

I am developing an iMessage app for iPhone. It currently allows the user to press the arrow to resize the app from keyboard size to full screen. For my app, the full screen view is not necessary.

Is it possible to disable the resizing in the iMessage app?

Thank you

Upvotes: 3

Views: 1004

Answers (2)

Shrawan
Shrawan

Reputation: 7246

In addition to above :- When the person Reply to message , there are 2 scenario

Active and Inactive state :-

Life Cycle of Active state :

iMessage Tap 

  func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) 

func didSelect(_ message: MSMessage, conversation: MSConversation) 

  func didTransition(to presentationStyle: MSMessagesAppPresentationStyle)

Life Cycle of InActive state :

iMessage Tap   

 didBecomeActive(with conversation: MSConversation)   func viewWillAppear(_ animated: Bool) 

  func viewDidAppear(_ animated: Bool)

So in the Inactive state willTransition will take control over it .

But in active state,you have no control of Transition so it will open in Expanded form by default. In didBecomeActive method you have to call below functions to transit to different style.

These function will help to move from one transition state to another in MessagesViewController:-

   requestPresentationStyle(.expanded) 
   requestPresentationStyle(.compact)

Above method will invoke willTransition and didTransition:-

  override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {

  //Here we can check the presentationStyle and move the Controller according to    need . i.e

    let controller: UIViewController
    if presentationStyle == .compact {
        controller = instantiateCompactController()
    }
    else {
        controller = instantiateExpandController()
    }

 //and then Present Controller 

}

For More Information : https://developer.apple.com/videos/play/wwdc2016/224/

Upvotes: 2

RomOne
RomOne

Reputation: 2105

I'm afraid this arrow will always call the full screen layout. You'll have to handle both. But here are some ideas:

  • When the user tap the arrow, it will fire the method didTransition(to: MSMessagesAppPresentationStyle). So you could requestPresentationStyle(_ presentationStyle: MSMessagesAppPresentationStyle) with a compact mode. So that when ever it try to go in full screen, it will go back to compact mode
  • Also I'm not sure, but you could maybe use requestPresentationStyle(_ presentationStyle: MSMessagesAppPresentationStyle) to always present compact mode, instead of extend mode.

Also have a look here : https://developer.apple.com/reference/messages/msmessagesappviewcontroller/1649184-requestpresentationstyle

They say this :

Note, however, that the user should have ultimate control over the extension’s presentation style. If the user chooses to change the presentation style, you should respect that choice.

Upvotes: 5

Related Questions