Is it possible to connect to a Multipeer session without an invitation?

I'm trying to create an application like FireChat, where users automatically connect to a Multipeer session without sending or receiving invitations to connect.

All the tutorials I've seen use the MCBrowserViewController. It should be possible to join a session without having to select a peer to connect and send and receive a connection request, if Firechat supports it.

Does anyone know how to do this?

thanks

+7
ios objective-c multipeer-connectivity
source share
1 answer

Instead of using the MCBroswerViewController, you can use the MCNearbyServiceBrowser. Then it will call the delegate method:

- (void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info; 

Then you can automatically send an invitation with something like:

 [browser invitePeer:peerID toSession:self.session withContext:nil timeout:10]; 

However, I encountered many other problems. So far it seems:

  • If both devices send invitations and accept them, they quickly turn off.
  • If both devices advertise and broadcast at the same time, they are randomly turned off.

I am currently working on an open source library to try to accomplish exactly what you are asking for: connect devices without any prompts or browser (without an interface).

Here it is: https://github.com/plivesey/PLPartyTime

However, it does not work yet. I have not completely resolved both questions above, but if you want to check the code and see what you can solve, go for it. Please let me know about any progress you are making. This structure is disappointing ...

+12
source share

All Articles