2

I am making an iMessage extension turn-based game.

I want to be able to check who (sender or receiver) opens the iMessage when it is tapped on. For example:

if the sender opens it:

remind them that it is the other persons turn

if the receiver opens it:

allow them to take their turn
quemeful
  • 8,148
  • 4
  • 51
  • 64

1 Answers1

3

You want to check the senderParticipantIdentifier of the selected MSMessage against the localParticipantIdentifier of the MSConversation.

Here is an example of how it can be done when the MSMessage will become active:

override func willBecomeActive(with conversation: MSConversation) {
   if let selectedMessage = conversation.selectedMessage {
        if conversation.localParticipantIdentifier == selectedMessage.senderParticipantIdentifier {
            // you sent this iMessage
        } else {
            // you recieved this iMessage
        }
    }
}
quemeful
  • 8,148
  • 4
  • 51
  • 64