The notification tab does not work in my multi peer connectivity program, is there something that I have to add to the info.plist? I am using objective c

/////////////////

-(id)init{

self = [super init];

if (self) {

_peerID = nil;

_session = nil;

_browser = nil;

_advertiser = nil;

}

return self;

}



-(void)setupPeerAndSessionWithDisplayName:(NSString *)displayName{

self.peerID = [[MCPeerID alloc] initWithDisplayName:displayName];

self.session = [[MCSession alloc] initWithPeer:self.peerID];

self.session.delegate = self;

}

-(void)setupMCBrowser{

self.browser = [[MCBrowserViewController alloc] initWithServiceType:@"game-stuff" session:_session];

}

-(void)advertiseSelf:(BOOL)shouldAdvertise{

if(shouldAdvertise) {

self.advertiser = [[MCAdvertiserAssistant alloc] initWithServiceType:@"game-stuff" discoveryInfo:nil session:self.session];

[self.advertiser start];

}

else{

[self.advertiser stop];

_advertiser = nil;

}

}

-(void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(nonnull MCPeerID *)peerID withDiscoveryInfo:(nullable NSDictionary<NSString *,NSString *> *)info

{

}

- (void)session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state {

NSDictionary *dict = @{@"peerID":peerID, @"state" : @(state)};//[NSNumber numberWithDouble:state]};

[[NSNotificationCenter defaultCenter] postNotificationName:@"MCDidChangeStateNotification" object:nil userInfo:dict];

}

1) please use the " <> " button above to post code.


2) you are posting lots of MCSession code and asking a question only about "notification tab" - and you are asking that question in the title of the post rather than in the post itself. Use the title as a title not a textfield. And what is "notification tab"?


3) assuming that your question relates to this line of code:

    [[NSNotificationCenter defaultCenter] postNotificationName:@"MCDidChangeStateNotification" object:nil userInfo:dict];

all you need to do to receive a notification is to add this line of code in any class in your project:


    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(ReceivedSomeNotification:)
                                                 name:@"MCDidChangeStateNotification" object:nil];


// and then receive it here in the same class as the addObserver above:
-(void)ReceivedSomeNotification:(NSNotification *)notification{


}
The notification tab does not work in my multi peer connectivity program, is there something that I have to add to the info.plist? I am using objective c
 
 
Q