У меня есть некоторые проблемы с NSNotificationCenter и didReceiveRemoteNotification. Я хочу открыть свой ViewController, когда получу новое уведомление от APNS. Внутри уведомления тела у меня есть objectId - это ключ. Я пытаюсь открыть свой ViewController в didReceiveRemoteNotification, но он не работает ((
AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[NSNotificationCenter defaultCenter]
postNotificationName:kDidReceiveRemoteNotification
object:userInfo];
}
НовостиDetailViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(didReceiveRemoteNotification:)
name:kDidReceiveRemoteNotification
object:nil];
}
- (void)didReceiveRemoteNotification:(NSNotification *)notification
{
NSLog(@"%s %@",__func__,[notification.userInfo description]);
}
Пост.ч
#define kDidReceiveRemoteNotification @"UIApplicationDidReceiveRemoteNotification"
ViewController не загружен. я не знаю, что делать.