Published on March 6, 2014
Multipeer Connectivity Framework http://alexruperez.com @alexruperez
Multipeer Connectivity Framework • Provides support for discovering services provided by nearby iOS devices using infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and subsequently communicating with those services by sending message-based data, streaming data, and resources (such as ﬁles). • This connection is not Android compatible, for Android devices you can use Wi-Fi Direct, although it is not as fast as Multipeer. http://alexruperez.com @alexruperez
MCPeerID • The MCPeerID class represents a peer in a multipeer session. • The Multipeer Connectivity framework is responsible for creating peer objects that represent other devices. Your app is responsible for creating a single peer object that represents the instance of your app that is running on the local device. • To create a new peer ID for the local app and associate a display name with that ID, call initWithDisplayName:. The peer’s name must be no longer than 63 bytes in UTF-8 encoding. http://alexruperez.com @alexruperez
MCAdvertiserAssistant • Handles advertising, presents incoming invitations to the user and handles users’ responses. This class should be used to provide a user interface for handling invitations when your app does not require programmatic control over the invitation process. • Before you can advertise a service, you must create an MCPeerID object that identiﬁes your app and the user to nearby devices. http://alexruperez.com @alexruperez
• initWithServiceType:(NSString*) serviceType discoveryInfo:(NSDictionary*) info session:(MCSession*) session • serviceType must be 1–15 characters long and can contain only ASCII lowercase letters, numbers, and hyphens. Ex. @“abc-txtchat” • info is just extra information to be broadcasted, may be nil. • Then simply start or stop the advertising. • For more customization check out MCNearbyServiceAdvertiser. http://alexruperez.com @alexruperez
MCAdvertiserAssistantDelegate • Describes the methods that the delegate object for an MCAdvertiserAssistant instance can implement to handle advertising-related events. • advertiserAssitantWillPresentInvitation: (MCAdvertiserAssistant*) advertiserAssistant • advertiserAssistantDidDismissInvitation: (MCAdvertiserAssistant*) advertiserAssistant http://alexruperez.com @alexruperez
MCBrowserViewController • Presents nearby devices to the user and enables the user to invite nearby devices to a session. To use this class, call methods from the underlying UIViewController class (performSegueWithIdentiﬁer:sender: for storyboards or presentViewController:animated:completion: for nib-based views) to present and dismiss the view controller. http://alexruperez.com @alexruperez
• initWithServiceType:(NSString*) serviceType session:(MCSession*) session • The maximumNumberOfPeers property represents max peers allowed in a session, including the local peer. The largest allowable value (and the default) is 8. • The minimumNumberOfPeers property represents min peers allowed in a session, including the local peer. The smallest allowable value (and the default) is 2. http://alexruperez.com @alexruperez
MCBrowserViewControllerDelegate • - (BOOL)browserViewController: (MCBrowserViewController*) browserViewController shouldPresentNearbyPeer:(MCPeerID*) peerID withDiscoveryInfo:(NSDictionary*) info • - (void)browserViewControllerDidFinish: (MCBrowserViewController*) browserViewController • - (void)browserViewControllerWasCancelled: (MCBrowserViewController*) browserViewController http://alexruperez.com @alexruperez
MCNearbyServiceBrowser • Searches (by service type) for services offered by nearby devices using infrastructure Wi-Fi, peer-to-peer Wi-Fi, and Bluetooth, and provides the ability to easily invite those devices to a Multipeer Connectivity session (MCSession). • You can create a custom MCBrowserViewController using your own MCNearbyServiceBrowser with initWithBrowser:session: http://alexruperez.com @alexruperez
MCSession • Enables and manages communication among all peers in a Multipeer Connectivity session. • initWithPeer:(MCPeerID*) myPeerID • The connectedPeers property is array of all peers that are currently connected to this session. http://alexruperez.com @alexruperez
• - (BOOL)sendData:(NSData*) data toPeers: (NSArray*) peerIDs withMode: (MCSessionSendDataMode) mode error:(NSError**) error • - (NSProgress*)sendResourceAtURL:(NSURL*) resourceURL withName:(NSString*) resourceName toPeer:(MCPeerID*) peerID withCompletionHandler: (void (^)(NSError *error))completionHandler • - (NSOutputStream*)startStreamWithName: (NSString*) streamName toPeer:(MCPeerID*) peerID error:(NSError**) error http://alexruperez.com @alexruperez
MCSessionSendDataMode • MCSessionSendDataReliable: The framework should guarantee delivery of each message, enqueueing and retransmitting data as needed, and ensuring in-order delivery. • MCSessionSendDataUnreliable: Messages to peers should be sent immediately without socket-level queueing. If a message cannot be sent immediately, it should be dropped. The order of messages is not guaranteed. This message type should be used for data that ceases to be relevant if delayed, such as real-time gaming data. http://alexruperez.com @alexruperez
Addendum • alexruperez/ARMultipeerConnectivityExample • Multipeer Connectivity Framework Reference • MultipeerGroupChat • tonyd256/TDAudioPlayer • pj4533/AVCaptureMultipeerVideoDataOutput http://alexruperez.com @alexruperez
About Multipeer Connectivity. Classes Protocols The Multipeer Connectivity framework provides support for discovering services provided ...
Multipeer Connectivity is a framework that enables nearby devices to communicate over infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth ...
The Multipeer Connectivity framework provides support for discovering services provided by nearby iOS devices using infrastructure Wi-Fi ...
Apple introduced the Multipeer Connectivity Framework in iOS 7. In this tutorial, we'll give an introduction of the framework and build a demo chat app.
Apples iOS 7 bietet mit Multipeer Connectivity Framework eine Vernetzungsmöglichkeit über WLAN und Bluetooth zwischen iOS-Geräten, ohne dass dafür eine ...
Apple gives a good high-level overview of how the Multipeer Connectivity Framework ... This allows you to be invited into a “session” with multiple ...
I wonder if this Multipeer Connectivity framework is ready for use in the real world, given all the bugs that have been encountered by the community.
I hope to use the Multipeer Connectivity framework, and would appreciate any voices of experience on how best to proceed. I need a connection between a ...
Prior to Xcode 5, we first would have needed to link the project against the Multipeer Connectivity framework. In Xcode 5, however, this is no longer ...
iOS 7’s Multipeer Connectivity framework lets you communicate with people without an internet connection Posted by Jason on Mar 23, 2014 | Comments (10)