我正在制作iMessage扩展回合制游戏。
我希望能够检查谁(发件人或收件人)在点击时打开iMessage。例如:
如果发件人打开它:
remind them that it is the other persons turn
如果接收者打开它:
allow them to take their turn
答案 0 :(得分:3)
您想要针对MSConversation的localParticipantIdentifier检查所选MSMessage的senderParticipantIdentifier。
以下是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
}
}
}