我在标准GameKit
文档中找不到有关球员如何宣传他们想参加比赛的信息的麻烦?有关于如何创建比赛并邀请正在等待的球员的文档,但是我无法解读一名球员如何做广告参加比赛并成为“等待”球员?
我相信提供invitation handler
是答案:
https://developer.apple.com/documentation/gamekit/gkmatchmaker
To receive invitations from other players, your game must provide an
invitation handler. After your game successfully authenticates the local
player, it should immediately set the inviteHandler property. The invite
handler is called immediately if your game was launched in response to a
push notification.
编辑:NOPE,此属性显然自iOS 7起已被弃用
在findMatch
上调用GKMatchmaker
可能会成功:
https://developer.apple.com/documentation/gamekit/gkmatchmaker/1520777-findmatch
// Auto-matching or invites to find a peer-to-peer match for the specified request. Error will be nil on success:
// Possible reasons for error:
// 1. Communications failure
// 2. Unauthenticated player
// 3. Timeout
// Note that the players property on the returned GKMatch instance will only contain connected players. It will initially be empty as players are connecting. Implement the GKMatchDelegate method match:player:didChangeConnectionState: to listen for updates to the GKMatch instance's players property.
open func findMatch(for request: GKMatchRequest, withCompletionHandler completionHandler: ((GKMatch?, Error?) -> Void)? = nil)