我正在使用UILocalNotification
,但它没有按时触发,而是在指定时间后 8-10 分钟通知我。这是我正在使用的代码
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSString *dateString = [dateFormat stringFromDate:[NSDate date]];
NSDate *notificationDate = [dateFormat dateFromString:dateString];
localNotif.fireDate = notificationDate;
localNotif.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
// Notification details
localNotif.alertBody = @"Appear";
// Set the action button
localNotif.alertAction = @"Action";
localNotif.soundName = UILocalNotificationDefaultSoundName;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
我在.didEnterRegion委托中使用它CLLocationManager
。我做错了什么?