本地通知被替换

时间:2014-08-31 15:22:08

标签: ios uilocalnotification

每当我的应用在后台收到重要的位置更新时,我都会显示本地通知。由于某种原因,通知每次都会覆盖先前的通知。我想在屏幕上显示所有本地通知,直到用户打开应用程序。我怎么能这样做?

这是我的代码:

NSString *message = [NSString stringWithFormat:@"Distance %.1f km",self.calculatedDistance];
[notification setAlertBody:message];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
[notification setTimeZone:[NSTimeZone  defaultTimeZone]];

NSDictionary *infoDict = [NSDictionary dictionaryWithObject:message forKey:@"msg"];
notification.userInfo = infoDict;

[[UIApplication sharedApplication] setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];

1 个答案:

答案 0 :(得分:0)

替换:

    [[UIApplication sharedApplication] setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];

使用:

    [[UIApplication sharedApplication] scheduleLocalNotification:notification];