I am receiving a remote notification. I want to post a nsnotification. I can post the notification, but I can't receive it in my current view controller.
Here is my code.
I know this gets called:
AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[NSNotificationCenter defaultCenter] postNotificationName:CHAT_MESSAGE_RECEIVED object:nil userInfo:messageIdDict];
}
This gets called before the above code gets called
MyViewController.m
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(messageReceived:)
name:CHAT_MESSAGE_RECEIVED
object:self];
}
-(void)messageReceived:(NSDictionary *)userInfo
{
NSLog(@"Logged");
}