Contents

startBrowsingForNearbyPlayers(handler:)

Finds nearby players through Bluetooth or WiFi on the same subnet.

Declaration

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

Parameters

  • reachableHandler:

    The block that GameKit calls when it completes the request.

    This block receives the following parameters:

    player

    The player whose reachability status changes.

    reachable

    True if a new nearby player appears. False if a previously discovered player disappears.

Discussion

Use the reachableHandler implementation to update your interface with information about nearby players. If the local player wants to invite a nearby player, call the findMatch(for:withCompletionHandler:) method to create a match or the addPlayers(to:matchRequest:completionHandler:) method to update an existing match. When you are done finding nearby players, call the stopBrowsingForNearbyPlayers() method.

See Also

Looking for nearby players