1

我已经在我的应用程序中实现了 UILocalNotification,并且在返回应用程序时遇到了问题。所有过去的通知都发送到-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

对于简单的测试,我正在运行以下代码:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
    NSLog(@"notification fired %@",notification.fireDate);
}

这导致 NSLog 的

2013-11-04 19:25:31.592 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:12:03 +0000
2013-11-04 19:25:31.599 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:11:03 +0000
2013-11-04 19:25:31.604 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:10:03 +0000
2013-11-04 19:25:31.612 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:09:03 +0000
2013-11-04 19:25:31.617 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:08:03 +0000
2013-11-04 19:25:31.626 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:07:03 +0000
2013-11-04 19:25:31.640 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:06:03 +0000
2013-11-04 19:25:31.648 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:05:03 +0000
2013-11-04 19:25:31.660 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:04:03 +0000
2013-11-04 19:25:31.671 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:03:03 +0000
2013-11-04 19:25:31.677 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:02:03 +0000
2013-11-04 19:25:31.685 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:01:03 +0000
2013-11-04 19:25:31.689 itsmedicinetime[8292:60b] notification fired 2013-11-05 00:00:03 +0000
2013-11-04 19:25:31.694 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:59:03 +0000
2013-11-04 19:25:31.707 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:58:03 +0000
2013-11-04 19:25:31.715 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:57:03 +0000
2013-11-04 19:25:31.722 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:56:03 +0000
2013-11-04 19:25:31.727 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:55:03 +0000
2013-11-04 19:25:31.733 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:54:03 +0000
2013-11-04 19:25:31.741 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:53:03 +0000
2013-11-04 19:25:31.746 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:52:03 +0000
2013-11-04 19:25:31.752 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:51:03 +0000
2013-11-04 19:25:31.757 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:50:03 +0000
2013-11-04 19:25:31.762 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:49:03 +0000
2013-11-04 19:25:31.771 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:48:03 +0000
2013-11-04 19:25:31.776 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:47:03 +0000
2013-11-04 19:25:31.780 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:46:03 +0000
2013-11-04 19:25:31.789 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:45:03 +0000
2013-11-04 19:25:31.795 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:44:03 +0000
2013-11-04 19:25:31.802 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:43:03 +0000
2013-11-04 19:25:31.807 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:42:03 +0000
2013-11-04 19:25:31.812 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:41:03 +0000
2013-11-04 19:25:31.820 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:40:03 +0000
2013-11-04 19:25:31.825 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:39:03 +0000
2013-11-04 19:25:31.831 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:38:03 +0000
2013-11-04 19:25:31.838 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:37:03 +0000
2013-11-04 19:25:31.843 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:36:03 +0000
2013-11-04 19:25:31.850 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:35:03 +0000
2013-11-04 19:25:31.857 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:34:03 +0000
2013-11-04 19:25:31.860 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:33:03 +0000
2013-11-04 19:25:31.866 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:32:03 +0000
2013-11-04 19:25:31.871 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:31:03 +0000
2013-11-04 19:25:31.876 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:30:03 +0000
2013-11-04 19:25:31.882 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:29:03 +0000
2013-11-04 19:25:31.885 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:28:03 +0000
2013-11-04 19:25:31.892 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:27:03 +0000
2013-11-04 19:25:31.896 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:26:03 +0000
2013-11-04 19:25:31.905 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:25:03 +0000
2013-11-04 19:25:31.909 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:24:03 +0000
2013-11-04 19:25:31.914 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:23:03 +0000
2013-11-04 19:25:31.927 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:22:03 +0000
2013-11-04 19:25:31.935 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:21:03 +0000
2013-11-04 19:25:31.942 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:20:03 +0000
2013-11-04 19:25:31.946 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:19:03 +0000
2013-11-04 19:25:31.954 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:18:03 +0000
2013-11-04 19:25:31.960 itsmedicinetime[8292:60b] notification fired 2013-11-04 23:17:03 +0000

我的理解是只有最后一个通知应该发送到这个方法,那么为什么我的应用程序创建的每个通知都被发送到那里?

最终目标是仅当应用程序是通过触摸横幅或从通知中心启动时才响应通知,如果应用程序是从其图标启动时忽略它。

4

0 回答 0