【问题标题】:Handle Push Notifications处理推送通知
【发布时间】:2012-09-02 00:34:52
【问题描述】:
我有一个简单的新闻应用程序,由 UINavigationController 、 UITableViewController 和 UIViewController 组成,当应用程序启动时,它会从网络加载新闻,然后当单击表格单元格时,它会转到另一个视图以显示全文,我已经添加了推送通知,但是我现在想处理它,所以当用户单击通知时,会出现带有文章的视图,如果用户单击后退按钮,它会转到新闻列表表,有人可以帮忙吗?
【问题讨论】:
标签:
objective-c
ios
cocoa-touch
push-notification
uilocalnotification
【解决方案1】:
在 application:didFinishLaunchingWithOptions: 你应该看看 launchOptions 字典中有什么。像这样的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
…
NSDictionary *userInfo = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
if ( userInfo != nil )
[self handlePushNotification: userInfo];
…
}
别忘了实现:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
以防推送通知在您的应用运行时出现。
在您的 handlePushNotification: 方法中,您应该手动创建视图堆栈,可能带有动画:NO。