Question

I want to use the new iOS 7 Multipeer Connectivity in my app where one person is a host, and anyone can join the host.

I have successfully implemented it using a combination of this tutorial and the Apple Developer Reference to Multipeer Connectivity.

What I want to do however, is add an extra layer of security so not just everyone can join the app. I want it so when a person requests to join the host, they must enter a random 4 digit pin code which the host will tell the group so people who know it can type it in and join the session.

Is this possible to do? As iOS 7 is so new, it is hard to find andy information on it.

Any help or suggestions would be much appreciated. Cheers

Was it helpful?

Solution

This absolutely is possible to do. When you invite your peer to connect to the service, you can send an NSData object to the advertiser. Just convert the pin code to an NSData object and send it to be checked on the advertising device.

You can find the relevant info on Apple's documentation site, with the context variable. Let me know if you need more guidance.

- (void)invitePeer:(MCPeerID *)peer
         toSession:(MCSession *)session
       withContext:(NSData *)context
           timeout:(NSTimeInterval)timeout
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top