Search code examples
iosios-app-extensionios10

Is there are way to open an iMessage extension from within the container app?


So far I've been encountering scenarios where you can launch the embedding app from the extension using the openURL: method, but is there a way to achieve the opposite?

I'm interested in knowing whether it would be possible to do something in my container app that creates an MSMessage instance and launches my iMessage app extension. Is this doable?


Solution

  • If anyone else is interested, as of Xcode 8.0 beta 6, MFMessageComposeViewController declares a property message of type MSMessage that lets you create an interactive message from within a springboard application so it can be used to achieve what I wanted in the first place. It does not, however, let you open a container app application.

    Here's my code:

    let message = MSMessage()
    message.url = // Your message url
    message.layout = MSMessageTemplateLayout()
    message.summaryText = // Summary text
    
    let messageViewControler = MFMessageComposeViewController()
    messageViewControler.message = message
    
    show(messageViewControler, sender: self)