UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [self.datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"Did you forget something?";
notif.alertAction = @"Show me";
if the user clicks on “showme” the app should open and he should get the alert.
Where should i write this code?and if possible someone please give me a little bit of code
You will get the notification about the UILocalNotification in two places depending on app’s state at the time the notification is fired.
1.In application:didFinishLaunchingWithOptions: method, if the app is neither running nor in the background.
2.In application:didReceiveLocalNotification: method if the app is either running or in background. Its almost useless to show the alert when the app is already running. So you have to show the alert only when the app was in background at the time the notification fired. To know if the app is resuming from background use the applicationWillEnterForeground: method.
Using this you can show the alert in didReceiveLocalNotification: method only when the app is resuming from background.
You can simply omit the if-condition if you want to show the alert view all the time the notification is fired regardless of the app’s state.