2014-08-31 50 views
0

每當我的應用在後臺收到重要的位置更新時,我都會顯示本地通知。出於某種原因,通知每次都會覆蓋先前的通知。我想保留屏幕上顯示的所有本地通知,直到用戶打開應用程序。我怎樣才能做到這一點?本地通知被取代

這裏是我的代碼:

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

替換:

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

有:

[[UIApplication sharedApplication] scheduleLocalNotification:notification];