Saturday, May 31, 2014

Multipeer Connectivity in iOS 7 Part 2

In the Part 1 of this series we discussed how we can do multipeer connectivity using the BrowserViewController. 

In this blog we will discuss how we can achieve the same programatically, you can also call it programmatic discovery. Doing this Programatically gives us:

  1. Flexibility
  2. Sending and Accepting Invitations Programmatically.
  3. Build a custom UI for discovery.
So if we are going to things manually, than we should know the classes involved in the process. All the classes which are related to the Multipeer Connectivity are available in the "MultipeerConnectivity.framework". 

Add the framework in the project and you can see the list of classes available in the framework. Out of all the classes which will interest you to start doing things are:
  • MCNearbyServiceAdvertiser
  • MCNearbyServiceBrowser
  • MCPeerID
  • MCSession

MCNearbyServiceAdvertiser

This classes helps you to publish the advertising through a specific service that your app is using and also notifies the delegate about invitations from the near by devices.

for more details about this class go to MCNearbyServiceAdvertiser Class Reference

MCNearbyServiceBrowser

This class helps you to search the services (of same service type) advertised by the near by devices over Wi-fi, Peer-Peer Wifi or Bluetooth. Once you browser the services than you can invite the peers for the connectivity for MCSession.

So as I mention the term Peer-Peer Wifi, so what this means. This means if there are say three devices involved in the connectivity and out of three devices as shown in image below.



As shown in the image the device at the top can connect to the device on the left through Device on the left as they can connected over wifi and device on the top is connected to the device on the left through Bluetooth only.

Multipeer Connectivity provides this infrastructure of Peer-Peer wifi connectivity. Which enables to connect the device at the Top and Device on the Left.

you can get the reference to the framework here : Multipeer Connectivity Framework

In the next blog we will do some coding and may be lead to a small app using the MultiPeerConnectivity.. :)

Happy Coding.

No comments:

Post a Comment