Reputation: 5220
I am having trouble finding information in the standard GameKit
documentation on how does a player advertise that they want to join some match? There is documentation on how to create a match and invite waiting players, but I can't decipher how does a player advertise to join a match and become this "waiting" player?
Here is a link to Apple's documentation https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html
Upvotes: 0
Views: 102
Reputation: 5220
Calling findMatch
on a GKMatchmaker
will probably do the trick:
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)
Upvotes: 1
Reputation: 5220
I believe that providing an invitation handler
is the answer:
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.
EDIT: NOPE, this property is apparently DEPRECATED since iOS 7
Upvotes: 0