Why does my MCSession peer disconnect randomly?

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.

Leave a Comment