Contents

startBrowsingForNearbyPlayers(reachableHandler:)

Enables the matchmaking process to find nearby players through Bluetooth or WiFi, but only on the same subnet.

Declaration

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

Parameters

  • reachableHandler:

    A block to call 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 GameKit discovers a new player locally, False if a previously discovered player disappears.

Discussion

Use this method only 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