Iphone推送通知服务中的问题

时间:2012-07-06 08:42:57

标签: iphone push-notification apple-push-notifications

iphone中的推送通知服务有一个小问题。 我在iphone中实现了推送通知,效果非常好。

我的问题是

应用程序关闭 - 当我的应用程序关闭时,当我收到通知警报时,点击通知的查看按钮我会进入我的警报视图页面。 在那个警报页面上,当我点击它时,我有一个后退按钮,我转到我修改的其他页面。

应用程序启动 - 当我的应用程序打开并且我在我的某个页面时。并且通知警报到来,点击通知的查看按钮我会转到我的警报视图页面,如上所述。 但现在当我点击后退按钮时,我想要通知之前的前一页。当app关闭时,不在固定页面上。

我应该如何在iPhone上执行此操作?

请分享您的逻辑/想法以解决我的问题?

1 个答案:

答案 0 :(得分:0)

每次从通知中定向时,请替换导航堆栈。 我们假设FirstViewController是您在单击后退按钮后要返回的位置。单击警报时,SecondViewController就是您要去的地方。

因此,每次从通知中引用时,请按

替换导航堆栈
FirstViewController  *objFirstViewController  = [[FirstViewController alloc] initWithNIBName: @"FirstViewController" bundle: nil];
SecondViewController *objSecondViewController = [[SecondViewController alloc] initWithNIBName: @"SecondViewController" bundle: nil];
NSArray *aryControllers = [NSArray arrayWithObjects: objFirstViewController,objSecondViewController, nil];
[self.navigationController setViewControllers: aryControllers animated: YES];
[objFirstViewController release];   
[objSecondViewController release];

当您从显示的视图中弹回时,您将始终获得FirstViewController。 以上是适用于您的应用不在后台(或已关闭)的情况。 对于您的应用在后台以及收到通知时的情况,

在AppDelegate application:didReceiveRemoteNotification:中,您可以在正常推送时推送视图。然后它将返回到您收到通知之前所在的上一页。(假设您在整个项目中使用全局导航控制器)

如果这对你有帮助,我很高兴。