I'm writing an app for iMessage and would like to automatically send the message when the user taps on the imessage app screen.
The message is composed of a map of an address of a location.
Originally, I had tried using the message.url to contain the maps.apple.com url, so that when the receiver taps on the received message it'll open up maps.
But that doesn't seem to work. So I've tried to send the address separately: first the image then the address. The receiver can then tap on the address and maps will open.
I have the following code:
if let image = createImageForMessage(), let conversation = activeConversation {
let layout = MSMessageTemplateLayout()
layout.image = image
let message = MSMessage()
message.layout = layout
//conversation.insert(message, completionHandler: nil)
//conversation.insertText("We are at:\n" + addressLabel, completionHandler: nil)
conversation.send(message, completionHandler: nil)
conversation.sendText("We are at:\n" + addressLabel, completionHandler: nil)
}
Ideally, I want it so that only the initial tap is required, but using "send" and "sendText" only sends the first "send" instruction, "sendText" is ignored.
If I used the commented out "insert" and "insertText" then both instructions are executed but I have to tap "send" to send it.
I have tried:
conversation.insert(message, completionHandler: nil)
conversation.sendText("We are at:\n" + addressLabel, completionHandler: nil)
But that didn't work. Only the text was sent. The image doesn't show up at all.
Does anyone know how to send both messages with just one tap?
Or, does anyone know if I can combine both messages into one?