I have a MultipeerService class which is used to start advertising and browsing sessions. For some reason I am not sure why I am not able to see any advertisers.
MultipeerService.m
-(void) startAdvertising
{
NSString *name = [[UIDevice currentDevice] name];
MCPeerID *peerId = [[MCPeerID alloc] initWithDisplayName:name];
self.session = [[MCSession alloc] initWithPeer:peerId];
self.session.delegate = self;
self.advertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:peerId discoveryInfo:nil serviceType:kServiceType];
self.advertiser.delegate = self;
[self.advertiser startAdvertisingPeer];
}
-(void) startBrowsing
{
NSString *name = [[UIDevice currentDevice] name];
MCPeerID *peerId = [[MCPeerID alloc] initWithDisplayName:name];
self.session = [[MCSession alloc] initWithPeer:peerId];
self.session.delegate = self;
self.browser = [[MCNearbyServiceBrowser alloc] initWithPeer:peerId serviceType:kServiceType];
self.browser.delegate = self;
[self.browser startBrowsingForPeers];
}
I start the advertiser like the following:
_multipeerConnectivityService = [[MultipeerConnectivityService alloc] init];
[_multipeerConnectivityService startAdvertising];
I create a new instance of multipeerConnectivityService for browsing and invoke the startBrowsing method.
When I check in the foundPeer method in the multipeerConnectivityService I see nothing invoked. What am I doing wrong?