本文主要讲述获取到推送消息之后,app的跳转。当我们在后台接受到推送消息时候,只有点击通知栏才能拿到推送内容,点击icon是拿不到的。
点击通知栏到这个方法里
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler ;
我们是在这个方法里面进行界面跳转的
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
//推送消息获取,极光官网有
//根据推送内容进行界面跳转,一步一步的跳转过去,这个好处是返回逻辑跟原来的一样,如果不想跟原来一样,可以自己修改
UITabBarController *tabbar = (UITabBarController *)self.window.rootViewController; //主控制器是tab+nav
UINavigationController *nav = tabbar.viewControllers[tabbar.selectedIndex];
[nav popToRootViewControllerAnimated:NO];
[tabbar setSelectedIndex:3];
nav = tabbar.viewControllers[3];
UIViewController *vc = nil;
vc = [[THAllBrightAgentVC alloc] init]; //创建自己的控制器
[nav pushViewController:vc animated:NO];
//如果在第三层,可以接着进行push
UIViewController * vc = [[THIncomeDetailVC alloc]init];
[nav pushViewController:vc animated:YES];
}