每当我的应用在后台收到重要的位置更新时,我都会显示本地通知。由于某种原因,通知每次都会覆盖先前的通知。我想在屏幕上显示所有本地通知,直到用户打开应用程序。我怎么能这样做?
这是我的代码:
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]];
答案 0 :(得分:0)
替换:
[[UIApplication sharedApplication] setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
使用:
[[UIApplication sharedApplication] scheduleLocalNotification:notification];