Note that there are some explanatory texts on larger screens.

plurals
  1. POAppdelegate function 'didreceivelocalnotification' is called immediately after the notification is created
    primarykey
    data
    text
    <p>I'm using <code>UILocalNotification</code>s in iPhone to create an alarm. Alarm is scheduled when I click a <code>UIButton</code>. My issue is that <code>– application:didReceiveLocalNotification:</code> is called when I click this button, that is when I create a local notification. But , <code>– application:didReceiveLocalNotification:</code> should be called only when the notification time is reached. I checked it on both simulator and device and got the same results. Can anyone help me with this...thanks in advance.</p> <pre><code>-(void)createalarm:(NSString *)datend_time:(NSString *)message//creating alarm { NSLog(@"created!!!!!!!!!!!!!"); NSString *datestr = datend_time; NSString *textstr = message; NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; [formatter setDateFormat:@"MM/dd/yyyy hh:mm a"]; NSDate *alerttime = [formatter dateFromString:datestr]; UIApplication * app = [UIApplication sharedApplication]; UILocalNotification *notification = [[UILocalNotification alloc] init]; if (notification) { notification.fireDate = alerttime; //notification.timeZone = [NSTimeZone defaultTimeZone]; notification.repeatInterval = 0; notification.alertBody = textstr; notification.soundName = UILocalNotificationDefaultSoundName; [app scheduleLocalNotification:notification]; [app presentLocalNotificationNow:notification]; } } -(void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification { NSLOG(@"delegate called") } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload