【问题标题】:Issue in Push Notification Service in IphoneIphone 中的推送通知服务问题
【发布时间】:2012-07-06 08:42:57
【问题描述】:
我在 iphone 的推送通知服务中有一个小问题。
我已经在 iphone 中实现了推送通知,效果很好。
我的问题是
应用程序关闭-当我的应用程序关闭并收到通知警报时,单击通知的查看按钮时,我会转到我的警报查看页面。
在那个警报页面上,当我单击它时,我有一个后退按钮,我转到另一个已修复的页面。
应用程序打开-当我的应用程序打开并且我在我的一个页面中时。通知警报来了,单击通知的查看按钮时,我会转到与上面相同的警报查看页面。
但是现在当我单击返回按钮时,我想转到通知之前的上一页。不在应用关闭时的固定页面上。
我应该如何在 iphone 中执行此操作?
请分享您的逻辑/想法来解决我的问题?
【问题讨论】:
标签:
iphone
push-notification
apple-push-notifications
【解决方案1】:
每次收到通知后,请更换导航堆栈。
假设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: 您可以像正常推送一样推送视图。然后它将返回到您收到通知之前所在的上一个页面。(假设您在整个项目中都使用全局导航控制器)
如果这对您有所帮助,我很高兴。