玩家如何以编程方式使用 GameKit 宣传他们想参加比赛?

How does a player programmatically using GameKit advertise they want to join some match?

我在标准 GameKit 文档中找不到有关玩家如何宣传他们想参加某场比赛的信息?有关于如何创建比赛和邀请等待玩家的文档,但我无法破译玩家如何做广告加入比赛并成为这个 "waiting" 玩家?

这里是 link Apple 文档 https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html

我相信提供 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.

编辑:不,这个 属性 自 iOS 7

以来显然已弃用

GKMatchmaker 上调用 findMatch 可能会成功:

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)