2016-09-19 24 views
1

我正在制作一个iMessage扩展回合制游戏。如何检查MSMessage是否被发送或接收?

我希望能够检查谁(发送者或接收者)在点击时打开iMessage。例如:

如果发件人它打开:

remind them that it is the other persons turn 

如果接收者打开它:

allow them to take their turn 

回答

2

你要检查所选MSMessage的senderParticipantIdentifier对MSConversation的localParticipantIdentifier。

这里是它如何做时,MSMessage将成为活跃的一个例子:

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 
     } 
    } 
} 
+0

这不是为我工作。他们是不同的。 –