I\'m having some really irritating problems with UILocalNotification
.
While finishing up an app that I\'ve nearly completed, I noticed that I couldn\'
UILocalNotification
s are only displayed automatically if the app is not running (or running in background). If the app is running and a local notification fires, UIApplicationDelegate
’s - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
method gets called and the system doesn’t display anything (nor does it play a sound). If you want to display the notification, create an UIAlertView
yourself in the delegate method.
one more thing, do not forget to show query whether to allow push, add below code to AppDelegate:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:settings];
}
}
Just a comment from my personal adventures in stupidity...
I had the same issue, but my problem was that I had forgotten to assign a value to alertBody. If you don't set alertBody, the notification won't display.