Why does my MCSession peer disconnect randomly?

前端 未结 5 1218
我寻月下人不归
我寻月下人不归 2020-11-29 18:36

Im using MCNearbyServiceBrowser and MCNearbyServiceAdvertiser to join two peers to a MCSession. I am able to send data between them using MCSession\'s sendData method. All

5条回答
  •  野性不改
    2020-11-29 19:24

    This is a bug, which I just reported to Apple. The docs claim the didReceiveCertificate callback is optional, but it's not. Add this method to your MCSessionDelegate:

    - (void) session:(MCSession *)session didReceiveCertificate:(NSArray *)certificate fromPeer:(MCPeerID *)peerID certificateHandler:(void (^)(BOOL accept))certificateHandler
     {
         certificateHandler(YES);
     }
    

    The random disconnects should cease.

提交回复
热议问题