0

如果在应用程序处于后台并且现在已进入前台时触发了本地通知,我需要运行特定代码。一种方法是获取徽章计数,有更好的方法吗?

4

1 回答 1

-2

在http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html查看文档

您的 App Delegate 可以在应用处于后台时检测通知

   - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {

    NSString *itemName = [notif.userInfo objectForKey:ToDoItemKey]

    [viewController displayItem:itemName];  // custom method

    application.applicationIconBadgeNumber = notification.applicationIconBadgeNumber-1;

}
于 2013-01-02T16:01:18.987 回答