I'm trying to use Multipeer Connectivity to connect iPhone Simulator on my mac with my iPhone. The app will get to the MCBrowserViewController, where I'll tap the iPhone Simulator and send an invitation to it. Then, I'll accept the invitation from my Mac and my phone will show me a "connecting..." However, the connection never succeeds, even though my mac and phone are less than 4 inches apart. This also doesn't work in reverse (i.e. when I send the invite from my mac)
I've tried the suggestions in this link but neither having separate advertiser and browser sessions nor commenting out the didReceiveCertificate seems to be working.
- (void)setupPeerWithDisplayName:(NSString *)displayName {
self.peerID = [[MCPeerID alloc] initWithDisplayName:displayName];
}
- (void)setupSession {
self.advertiseSession = [[MCSession alloc] initWithPeer:self.peerID];
self.advertiseSession.delegate = self;
self.browserSession = [[MCSession alloc] initWithPeer:self.peerID];
self.browserSession.delegate = self;
}
- (void)setupBrowser {
self.browser = [[MCBrowserViewController alloc] initWithServiceType:@"m117" session:self.browserSession];
}
- (void)advertiseSelf:(BOOL)advertise {
if (advertise) {
self.advertiser = [[MCAdvertiserAssistant alloc] initWithServiceType:@"m117" discoveryInfo:nil session:self.advertiseSession];
[self.advertiser start];
} else {
[self.advertiser stop];
self.advertiser = nil;
}
}
...
-(void)session:(MCSession *)session didReceiveCertificate:(NSArray *)certificate fromPeer:(MCPeerID *)peerID certificateHandler:(void (^)(BOOL))certificateHandler {
certificateHandler(YES);
}