Come check out Multi-Peer Connectivity, a brand new framework for connecting multiple devices in a peer-to-peer network. We'll learn how to get a basic application up and running and take advantage of these new APIs to create a whole new interactive dynamic in your apps.
3. Multi-Peer Connectivity
•
New in iOS 7
•
Ability to connect to a mesh of peers.
•
Able to connect to peers over WiFi, ad-hoc wireless, and Bluetooth.
•
Peers must be ‘nearby’.
11. Advertiser: Accept Invitation
- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:
(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void(^)(BOOL accept,
MCSession *session))invitationHandler
{
// In most cases you will want to give users an option to connect or not.
invitationHandler(YES, self.currentSession);
[self.advertiser stopAdvertisingPeer]; // Once invited, stop advertising
}
17. Best Practices
•
Keep messages short.
•
Be careful with inviting/accept invitations.
•
As an advertiser, once you have accepted an invitation, stop advertising.