Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was having the same problem, and it seems to have been related to my app browsing and advertising at the same time, and two invitations being sent/accepted. When I stopped doing this and let one peer defer to the other for invitations the devices stayed connected.</p> <p>In my browser delegate I'm checking the hash value of the discovered peer's <code>displayName</code> and only sending an invitation if my peer has a higher hash value:</p> <p><strong>Edit</strong></p> <p>As pointed out by @Masa the <code>hash</code> value of an <code>NSString</code> will be different on 32 and 64 bit devices, so it's safer to use the <code>compare:</code> method on <code>displayName</code>. </p> <pre><code>- (void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info { NSLog(@"Browser found peer ID %@",peerID.displayName); //displayName is created with [[NSUUID UUID] UUIDString] BOOL shouldInvite = ([_myPeerID.displayName compare:peerID.displayName]==NSOrderedDescending); if (shouldInvite){ [browser invitePeer:peerID toSession:_session withContext:nil timeout:1.0]; } else { NSLog(@"Not inviting"); } } </code></pre> <p>As you say, the documentation is sparse so who knows what Apple really wants us to do, but I've experimented with both sending and accepting invitations using a single session, and also creating a new session for each invitation accepted/sent, but this particular way of doing things has given me the most success. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload