[英]How can I tell if a local notification was fired while the application was in the background?
I need to run specific code if a local notification was fired while the application was in the background and has now entered the foreground. 如果在应用程序处于后台并且现在进入前台时触发了本地通知,则我需要运行特定的代码。 One way to do this is to get the badge count, is there a better way?
一种方法是获取徽章计数,还有更好的方法吗?
Check out the docs at http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html 在http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html上查看文档
Your App Delegate can detect notifications when the app is in the background 当应用程序在后台运行时,您的应用程序代表可以检测到通知
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
NSString *itemName = [notif.userInfo objectForKey:ToDoItemKey]
[viewController displayItem:itemName]; // custom method
application.applicationIconBadgeNumber = notification.applicationIconBadgeNumber-1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.