I am trying to fire local notification in my app and I am using the following the code -
-(void)applicationDidEnterBackground:(UIApplication *)application {
NSDate *alarmTime=[[NSDate date] dateByAddingTimeInterval:5.0];
UIApplication *app=[UIApplication sharedApplication];
UILocalNotification *notifiArea=[[UILocalNotification alloc] init];
if (notifiArea) {
notifiArea.fireDate=alarmTime;
notifiArea.timeZone=[NSTimeZone defaultTimeZone];
notifiArea.repeatInterval=0;
notifiArea.soundName=@"";
notifiArea.alertBody=@"This is a push notification";
[app scheduleLocalNotification:notifiArea];
}
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
UIApplication *app=[UIApplication sharedApplication];
NSArray *oldNotifications=[app scheduledLocalNotifications];
if([oldNotifications count]>0){
[app cancelAllLocalNotifications];
}
}
now when I'm debugging the app my alarm time is coming 2 017-04-24 11:27:51 +0000
but my simulator timing is 4:55pm
.
What is the problem?
运行代码后,您已回到家中或在模拟器中锁定了屏幕。日期始终取当前区域,直到我们设置另一个时区。因此,如果您的闹钟时间与模拟器时间不匹配,请放心,这不是发布它只是显示。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.