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

问题描述 投票:0回答:2

我在标准GameKit文档中找不到有关球员如何宣传他们想参加比赛的信息的麻烦?有关于如何创建比赛并邀请正在等待的球员的文档,但是我无法解读一名球员如何做广告参加比赛并成为“等待”球员?

这里是指向苹果文档https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html的链接

ios gamekit
2个回答
0
投票

我相信提供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起已被弃用


0
投票

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)
© www.soinside.com 2019 - 2024. All rights reserved.