0

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?

SiHa
  • 7,830
  • 13
  • 34
  • 43
Raman Srivastava
  • 396
  • 1
  • 14

1 Answers1

0

After run the code have you gone to the home or screen lock in simulator.Date always taking current zone until we will set the another timezone.So if your alarm time is not matching with simulator time,Don't worry,This is not the issue it just showing.

Shabbir Ahmad
  • 615
  • 7
  • 17