2016-09-19 50 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

這不是爲我工作。他們是不同的。 –