首页 > 解决方案 > 如何确定 receivedTurnEventFor 是否是邀请?

问题描述

在阅读了各种问题后,我了解到 GKTurnBasedMatches 的邀请要等到轮到被邀请的用户时才会发送。该邀请是通过“ func player(_ player: GKPlayer, receivedTurnEventFor match” 类处理的。

但我不确定此时如何处理邀请?我想为用户提供接受/拒绝邀请的机会。这是我应该写代码的地方:

如果收到回合事件 == 邀请 { 请求拒绝/接受 }

如果是这样,我该怎么做?如何确定是否有邀请,以及如何接受/拒绝该邀请?

标签: swiftgame-center

解决方案


我相信我已经通过使用以下代码解决了这个问题:

  if match.currentParticipant?.status == .invited {
           print("Was invited")
// Present option to act on invite
}

推荐阅读