push 通知時の didReceiveRemoteNotification: から UINavigationController で pop しても効かない件

didReceiveRemoteNotification: では

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

と NSNotificationCenter に通知。各 ViewController でこの通知を受けて ViewController の変更をするようにする。


例えば ViewController の init 系で observer になる。

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


で通知を受けたら ViewController で遷移。この場合は root の ViewController で refresh したかった。

- (void)pushNotificationReceived:(NSNotification*)notification
{
    [ViewHelper setViewNeedsRefresh:YES];
    [self.navigationController popToRootViewControllerAnimated:NO];
}

参照

iphone - Changing view from within didReceiveRemoteNotification - Stack Overflow http://stackoverflow.com/questions/7603712/changing-view-from-within-didreceiveremotenotification