iOS 点击远程通知消息,如何跳转到指定页面(控制器)
2016-03-07 17:02
555 查看
可能大家对跳转到任意控制器的理解有点不同。我自己的做法是通过通知来进行跳转的。appdelegate代理中接收到消息,将userInfo消息通过通知传出去,再此期间,需将跳转的控制器获取出来,接着其实就是获取你点击的某个控件比如cell的id传到那个控制器。然后在该控制器接收通知
就我自己的项目来说:
就我自己的项目来说:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if (application.applicationState == UIApplicationStateActive) { NSLog(@"active"); //程序当前正处于前台 [application setApplicationIconBadgeNumber:0]; NSString *messageAlert = [[userInfo objectForKey:@"aps"]objectForKey:@"alert"]; UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"远程通知" message:messageAlert delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"前往", nil]; alertView.delegate = self; [alertView show]; // 8秒后将退出弹框 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [alertView dismissWithClickedButtonIndex:0 animated:YES]; }); } else if(application.applicationState == UIApplicationStateInactive) { NSLog(@"inactive"); //程序处于后台 [[NSNotificationCenter defaultCenter]postNotificationName:@"123456" object:nil userInfo:userInfo]; } // IOS 7 Support Required [APService handleRemoteNotification:userInfo]; completionHandler(UIBackgroundFetchResultNewData); } 在你首页控制器的添加通知,并且跳转到每个控制器 - (void)viewdidload { [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(pushNotification:) name:@"123456" object:nil]; } - (void)pushNotification:(NSNotification *)notification { NSDictionary *dict = notification.userInfo; // kpiid 其实就是后台传出来需要点击cell的id GTLog(@"===notification===%@",[dict valueForKey:@"kpiid"]); [self selectKPIModuleId:[[dict valueForKey:@"kpiid"] integerValue]]; } /************************************************ * * * 点击相对应的kpiid模块,跳转到相对应的kpi控制器 * * ************************************************/ - (void)selectKPIModuleId:(int)kpiid // 此处是tableview didselect方法中单独提取的方法 { //销售利润 if(kpiid==1){ ProfitViewController *pyc=[[ProfitViewController alloc] initWithNibName:@"ProfitViewController" bundle:nil]; [(UINavigationController *)self.mm_drawerController.centerViewController pushViewController:pyc animated:YES]; [[TimeTool sharedTimeTool] timeToolBTypeOfStartWhenIntoViewCurrentModuleID:1]; return; }
相关文章推荐
- iOS图片裁剪
- iOS同步后couldn't load project
- ios7状态栏重叠问题的解决方法
- iOS 点击远程通知消息,跳转到指定页面 (控制器)
- IOS 核心动画之CAKeyframeAnimation - iBaby
- IOS的WebView请求远程html并加载本地资源
- IOS学习 scrollView的代理
- 在iOS开发中如何优雅地进行图片缩放?
- iOS 各种报错集合
- iOS后台运行机制1
- iOS WebSocket详解
- NETBIOS名 和 Host名的不同
- IOS字符串自动计算文本的宽和高
- ios开发——日常之XCode 文件后面带有问号的问题怎么解决??
- IOS There was an internal API error 错误
- IOS中获取各个文件的目录路径的方法和NSFileManager类
- iOS中书写代码规范34条小建议
- ios开发 ad hoc
- iOS 视图,动画渲染机制探究
- iOS 原生地图定位