I know that with an iMessage extension, a message can not be sent unless the app detects user interaction as per Apple's policy to prevent automated messages.
However, I have a screenshot detector that automatically sends a message when the user screenshots it.
When the extension is already open, and the selects a message and screenshots it, everything works because there was previous interaction in opening the app.
However, if you tap the message directly without the extension being open and screenshot it, iMessage won't send the message.
I would like to know one of two things:
- How to bypass and send the message anyways (less likely to work)
- How to check if there has been interaction before displaying the message
Please let me know if you have any ideas.
activeConversation?.send(message) { error in
print(error)
}
Here is the error I am pretty sure. However, I did check and active conversation is not nil
Optional(Error Domain=com.apple.messages.messagesapp-error Code=9 "(null)")
Are you testing in the debugger and have you confirmed it still fails without debugging?
As I just answered in this question there is an XCode bug which causes crashes when you have the info.plist key to give you camera permission.
It's a weird side-effect and it took me nearly two days to work out that was happening (I had added the info.plist keys weeks before testing sending messages).