Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iMessage Extensions: Root Navigation Controller results in all delegate methods to not get called in my MSMessagesAppViewController

I have a new iMessage Extension project where I tried 2 ways of structuring the navigation stack:

  1. In my storyboard I set the entry point to a UINavigationController that has my MSMessagesAppViewController as the root controller.

  2. Or I set my MSMessagesAppViewController directly as the Entry point in my storyboard. (No UINavigationController that owns it).

For scenario #1 above, the navigation controller works fine, and I can push new screens on the stack. (with the exception of the whole nav bar being hidden in Expanded view, which is a separate issue that I still have to figure out). However, NONE of the delegate methods of my MSMessagesAppViewController get called with this configuration. Such as: willTransitionToPresentationStyle didTransitionToPresentationStyle, willBecomeActiveWithConversation, didSelectMessage (none of these get called)

For scenario #2 above, the MSMessagesAppViewController methods DO get called. (because the UINavigationController is not the entry point in the Storyboard).

So my question is: How can I have a UINavigationController be at the root of my iMessage Extension application, so I can perform Push navigation, but at the same time have the methods of MSMessagesAppViewController get called, as described by the Apple API?

like image 427
FranticRock Avatar asked Jul 05 '17 18:07

FranticRock


1 Answers

Although it doesn't seem to be documented, it looks like message extensions expect the entry point to be a subclass of MSMessagesAppViewController. Those methods aren't delegate methods, they're superclass overrides, so there's no way to arrange for them to go anywhere else. The message extension system could handle the case you describe but-- aparently-- does not.

What I'd try is:

  • Make the entry point a subclass of MSMessagesAppViewController.
  • Early in that object's life cycle (maybe in viewDidLoad) create a UINavigationController and add it as a child view controller of your MSMessagesAppViewController subclass. Make it fill the entire screen.

Now-- in effect-- your navigation controller is the root of the extension. It's not really the root since message events like willTransitionToPresentationStyle will still go through the MSMessagesAppViewController subclass. But everything else starts there. It's the root of the UI and the navigation.

In the meantime it might be good to file an enhancement request with Apple. It's reasonable to think that the message extension system would check the root VC of a navigation controller to see if it's the right class, and maybe they'll add that in the future.

like image 137
Tom Harrington Avatar answered Nov 03 '22 09:11

Tom Harrington