我有一个 iPhone 应用程序,我在其中添加推送通知。
当我收到推送通知时,我需要在此处调用Web 服务后转到要加载表格视图的特定视图。问题是当我站在同一个视图中时。如果我收到推送消息,我需要在前台和后台重新加载 tableview。但是当我这样做时,它无法正常工作。我如何实现这一目标?
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"########################################didReceiveRemoteNotification****************************###################### %@",userInfo);
// Check application in forground or background
if (application.applicationState == UIApplicationStateActive)
{
if (tabBarController.selectedIndex==0)
{
NSArray *mycontrollers = self.tabBarController.viewControllers;
NSLog(@"%@",mycontrollers);
[[mycontrollers objectAtIndex:0] viewWillAppear:YES];
mycontrollers = nil;
}
tabBarController.selectedIndex = 0;
//NSLog(@"FOreGround");
//////NSLog(@"and Showing %@",userInfo)
}
else {
tabBarController.selectedIndex = 0;
}
}