Instance Method

startBrowsingForNearbyPlayers(reachableHandler:)

Enables the matchmaking process to find nearby players through Bluetooth or WiFi (same subnet only).

Declaration

func startBrowsingForNearbyPlayers(reachableHandler: ((String, Bool) -> Void)? = nil)

Parameters

reachableHandler

A block called when the reachability for a player changes. The block takes the following parameters:

playerID

The player identifier for the player whose reachability status has changed.

reachable

true if a new player has been discovered locally, false if a previously discovered player has disappeared.

Discussion

You only use this method when you are implementing programmatic matchmaking. After enabling browsing for nearby players, use the responses to populate your user interface with information about nearby players. If a player wants to invite a player to a game, add that player’s player identifier to a match request and call either the findMatch(for:withCompletionHandler:) to create a match or addPlayers(to:matchRequest:completionHandler:) method to update a match.

See Also

Deprecated Methods and Properties

func cancelInvite(toPlayer: String)

Cancels a pending invitation to another player.

Deprecated
var inviteHandler: ((GKInvite, [Any]?) -> Void)?

A block to be called when an invitation to join a match is accepted by the local player.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software