So basically I have been trying to create a very simple iMessage application where when a button is pressed, it inserts a message into the conversation a bit like what can be seen in this tutorial: The only issue I am having is that when the button is pressed, it runs the function however, nothing occurs as a result and I am really unsure as to why this is the case. I have been struggling with finding a working solution to this problem for a little while now and would really appreciate if someone would be kind enough to take a quick look at my code and perhaps point out where I went wrong or if I'm missing something. Any help on the topic will be greatly appreciated, thank you.
@IBAction func funcSend(_ sender: Any) {
let conversation = activeConversation
let session = conversation?.selectedMessage?.session
let layout = MSMessageTemplateLayout()
layout.caption = "Hi there"
var components = URLComponents()
let queryItem = URLQueryItem(name: "key", value: "value")
components.queryItems = [queryItem]
let message = MSMessage(session: session!)
message.layout = layout
message.url = components.url
message.summaryText = "Sent hi there message"
conversation?.insert(message)
}