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 2017-04-24 11:27:51 +0000
but my simulator timing is 4:55pm
.
What is the problem?