Contents

nearbyConnectionData(forPeer:withCompletionHandler:)

Obtains connection data for the specified peer.

Declaration

func nearbyConnectionData(forPeer peerID: MCPeerID, withCompletionHandler completionHandler: @escaping  @Sendable (Data?, (any Error)?) -> Void)
func nearbyConnectionData(forPeer peerID: MCPeerID) async throws -> Data

Parameters

  • peerID:

    A peer ID object obtained from the nearby peer that you want to add to a session.

  • completionHandler:

    A handler that is called when connection data is available or when an error occurs.

Discussion

This method provides connection data that is required when adding a specific nearby peer to a session if you are using your own service discovery code instead of an MCNearbyServiceBrowser or MCBrowserViewController object. For more information, see the Managing Peers Manually section in the overview of the MCSession class reference.

See Also

Managing Peers Manually