The MultipeerConnectivity namespace provides local (WiFi/Bluetooth) peer-to-peer messaging and data connections.
A convenience class that manages the process of advertising for multipeer connectivity and interacting with the application user.
A delegate object that provides events for the presentation or dismissal of an invitation by a MCAdvertiserAssistant.
A delegate object that provides events relating to the presentation of discovered peers and the application user's selection or cancellation of them.
Extension methods for the MultipeerConnectivity.MCError enumeration.
Provides programmatic control for advertising the device for multipeer connectivity.
A delegate object that exposes events relating to advertising and invitations for multipeer connectivity for a MCNearbyServiceAdvertiser object.
Allows programmatic browsing for devices advertising for multipeer connetivity.
A delegate object that exposes peer-discovery events for a MCNearbyServiceBrowser object.
Identifies a device in a multipeer connectivity network.
Represents a persistent connection between multiple devices.
A delegate object whose functions relate to events in the MCSession life-cycle, such as connection status changes and data reception.
Interface representing the required methods (if any) of the protocol MCAdvertiserAssistantDelegate.
Interface representing the required methods (if any) of the protocol MCBrowserViewControllerDelegate.
Interface representing the required methods (if any) of the protocol MCNearbyServiceAdvertiserDelegate.
Interface representing the required methods (if any) of the protocol MCNearbyServiceBrowserDelegate.
Interface representing the required methods (if any) of the protocol MCSessionDelegate.
An enumeration whose values specify whether an MCSession should encrypt its connection. Used with
An enumeration whose values specify various errors relating to multipeer connectivity.
An enumeration whose values specify whether a message's delivery is guaranteed. Used with SendData(NSData, MCPeerID, MCSessionSendDataMode, NSError).
An enumeration whose values indicate the state of a MCSession. Used with DidChangeState(MCSession, MCPeerID, MCSessionState).
The delegate that serves as the invitation handler in calls to DidReceiveInvitationFromPeer(MCNearbyServiceAdvertiser, MCPeerID, NSData, MCNearbyServiceAdvertiserInvitationHandler).
A delegate that serves as the completion handler for NearbyConnectionDataForPeer(MCPeerID, MCSessionNearbyConnectionDataForPeerCompletionHandler).
Introduced in iOS 7, Multipeer Connectivity (MPC) allows iOS devices to discover and communicate with other nearby iOS devices. "Nearby" devices are those within Bluetooth range, on the same WiFi network segment, or using WiFi peer connectivity. Additionally, MPC can bridge through connected peers: a WiFi-only iOS device can bridge to a Bluetooth-only iOS device via a peer that has both WiFi and Bluetooth . MPC is considerably easier to use than Zero-Configuration Networking (zeroconf), but MPC is not available for cross-platform scenarios.
Multipeer Connectivity has two phases: discovery and the session. The role of the discovery phase is to associate an MCSession object on each device with an MCSession object on the peer devices. In the session phase, the MCSession object is the channel through which devices communicate and its lifecycle events are associated with connections, disconnections, transmissions, and receptions.
The MCSession is instantiated by the application developer. During the discovery phase, there are two roles: advertisers that broadcast their willingness to connect to a certain protocol and browsers that discover these advertisers and invite them to sessions.
Advertising is managed by either the stock MCAdvertiserAssistant or custom controller that uses a MCNearbyServiceAdvertiser. Similarly, browsing is managed by a
The following image shows the sequence of functions with programmatic advertising and browsing:
|Create a new MCNearbyServiceAdvertiserDelegate and assign it to the Delegate property.||Create a new MCNearbyServiceBrowserDelegate and assign it to Delegate property.||Discovery and connection is taken care of by the delegate objects for the MCNearbyServiceAdvertiser and MCNearbyServiceBrowser.|
|The advertiser may instantiate a new MCSession now or wait until it receives an invitation.||Instantiate a new MCSession.||The browser should maintain a reference to a single MCSession object no matter how many peers ultimately connect.|
||Advertiser and browser must use identical |
|The system will call FoundPeer, passing in a reference to the MCNearbyServiceBrowser. The application developer calls InvitePeer, passing in a reference to the previously-created MCSession.||The callback is likely to occur on a background thread. If the application developer wishes to update the display, they must use |
|The system will call DidReceiveInvitationFromPeer. To connect the devices, the application developer must invoke the passed-in ||The callback is likely to occur on a background thread. If the application developer wishes to update the display, they must use |
|Once the devices are connected, the MCSession objects can be used to transmit messages and data between devices.|
Send feedback about: