TechnologiesNetworking & Connectivity

MultipeerConnectivity

iOSmacOStvOSwatchOSvisionOS

MultipeerConnectivity discovers nearby peers and exchanges data over Wi-Fi, peer-to-peer Wi-Fi, and Bluetooth, without requiring an internet connection. You advertise your device with MCNearbyServiceAdvertiser and find others with MCNearbyServiceBrowser, identify each participant by an MCPeerID, and connect them through an MCSession whose MCSessionDelegate reports state changes via MCSessionState and delivers received data. For interactions that need a built-in interface, MCAdvertiserAssistant and MCBrowserViewController present standard discovery and invitation flows, while MCEncryptionPreference and MCSessionSendDataMode let you control how connections are secured and how data is sent.

Essentials 3

The core objects that identify peers and establish a connected multipeer session.

  • Cl
    MCPeerID
    An object that uniquely identifies a peer device in a multipeer session by a display name.
  • Cl
    MCSession
    An object that manages connections among nearby peers and exchanges data, streams, and resources between them.
  • Pr
    MCSessionDelegate
    A protocol that handles peer state changes and the receipt of data, streams, and resources in a session.

Advertising a Service 2

Types that publish your device so nearby peers can discover and invite it.

  • Cl
    MCNearbyServiceAdvertiser
    An object that advertises a device's availability for a named service so nearby browsers can discover it.
  • Pr
    MCNearbyServiceAdvertiserDelegate
    A protocol that handles invitations received by an advertiser and reports advertising errors.

Browsing for Peers 2

Types that find nearby advertised peers and send connection invitations.

  • Cl
    MCNearbyServiceBrowser
    An object that searches for nearby advertised peers and sends them invitations to join a session.
  • Pr
    MCNearbyServiceBrowserDelegate
    A protocol that reports discovered and lost peers and browsing errors to a browser.

Built-in Discovery Interfaces 4

Standard system UI for advertising and for browsing and inviting peers.

  • Cl
    MCAdvertiserAssistant
    An object that advertises a service and presents a standard interface for handling invitations from nearby peers.
  • Pr
    MCAdvertiserAssistantDelegate
    A protocol that responds to the presentation and dismissal of an advertiser assistant's invitation interface.
  • Cl
    MCBrowserViewController
    A view controller that presents a standard interface for browsing nearby peers and inviting them to a session.
  • Pr
    MCBrowserViewControllerDelegate
    A protocol that responds to the user finishing or canceling browsing in a browser view controller.

Connection and Transport Options 3

Enumerations that control session encryption, connection state, and how data is delivered.

  • En
    MCSessionState
    Constants that indicate the current connection state of a peer in a session.
  • En
    MCEncryptionPreference
    Constants that specify whether a session requires, prefers, or disables encryption for peer connections.
  • En
    MCSessionSendDataMode
    Constants that specify whether session data is sent reliably or as best-effort unreliable delivery.

Errors 1

The error type reported by MultipeerConnectivity operations.

  • St
    MCError
    A structure that describes errors reported by MultipeerConnectivity operations.
← Networking & Connectivity