Open view controller when APNS is received in iOS

梦想与她 提交于 2019-12-05 20:57:28
//For redirect to the view
    UIViewController *uvc;
    if([notificationType isEqualToString:@"Notify"]){

        UIViewController *updates = [[UpdatesViewController alloc] initWithNibName:@"UpdatesViewController" bundle:nil];
        // add updates specific data updates.data = [aps objectForKey:@"data"];
        uvc = updates;
    }

    else if([notificationType isEqualToString:@"Voting "]) {
        UIViewController *voting = [[VotingViewController alloc] initWithNibName:@"VotingViewController" bundle:nil];
        // add voting specific data voting.data = [aps objectForKey:@"data"];
        uvc = voting;
    }
    [self.window.rootViewController presentViewController:uvc animated:YES completion:NULL];
M.J

you should check the aps in didFinishLaunchingWithOptions. didReceiveRemoteNotification only works when app is running or suspended.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!