1

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);
}
Community
  • 1
  • 1
Quikdart
  • 53
  • 2
  • 7
  • Are your mac and your iPhone connected to the same wifi network? I ran into this issue myself and that's what I guessed the problem was but never verified (because I ended up just getting another iOS device). I guessed this was the problem because I was able to connect between mac and device on my home wifi but not at the office, only later to discover that the mac and device had been connected to different wifi networks at the office. – tarrball May 31 '16 at 15:29

0 Answers0