Search code examples
objective-cswiftios10ios-extensionsimessage-extension

DidSelect method not getting called when tap on message in iMessage Extension


I am developing iMessage Extension, but didSelect(_ message: MSMessage, conversation: MSConversation) not getting called always, sometimes it called. But not getting when it calls and when not. According to my observation after launch of extension, on first time tap on message method will call, but after that method not getting called.I want to track every tap on message.

Is there any way to identify tap on message in iMessage Extension?

override func didSelect(_ message: MSMessage, conversation: MSConversation) {

    super.didSelect(message, conversation: conversation)
    isExpandingFromMessage = true

}

Below is image from my iMessage Extension and want to identify event when user tap on message.

enter image description here


Solution

  • The method is called "didSelect", not "didTap", so it only fires when you initially select the message. You can find this behavior defined at https://developer.apple.com/reference/messages/msmessagesappviewcontroller

    func didSelect(MSMessage, conversation: MSConversation)

    Invoked after the system updates the conversation’s selectedMessage property in response to the user selecting a message object in the transcript."

    If you want to track all taps on the message, you might try adding a UITapGestureRecognizer to the message view.