1

I have designed an iMessage extension app in which the initial/first view has a button "enter" and when we click "enter" it opens a second view which has one more button "send". I want to send a message using MSMessage when I click "send". My code for when "send" is pressed is:

let layout = MSMessageTemplateLayout()
layout.image = UIImage(named: "demo.png")!
layout.caption = "I am sending you this image"

let message = MSMessage()
message.layout = layout

activeConversation.insert(message, correctionHandler:nil)

But when I click "send" no action is performed. When I paste the same code inside "enter" button being pressed it works fine. Is there a way I can make this code work even from the second view, i.e. in my case when "send" button is pressed?

1 Answers1

0

Somewhere you need a call to MSMessagesAppViewController.dismiss() which closes the extension and puts focus back to the message bubble. Your cited code doesn't show that.

Everything else you are doing looks fine, just missing that final step.

In my app all my other VCs have a property pointing back to the original MSMessagesAppViewController instance so they can call a sendMessage function.

Andy Dent
  • 17,045
  • 6
  • 80
  • 109