Local Notification not working since updating to IOS 8 and Xcode 6
15,046
Solution 1
You need to update your code to be able to receive notifications in iOS8. More info here.
Objective-C code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
// Override point for customization after application launch.
return YES;
}
Swift Code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
//registering for sending user various kinds of notifications
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound|UIUserNotificationType.Alert |UIUserNotificationType.Badge, categories: nil)
// Override point for customization after application launch.
return true
}
Solution 2
In order to receive Local NSNotification, follow the below steps:
-
Add code into your
appDelegate.h
indidFinishLaunchingWithOptions
methodif ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; }
Related videos on Youtube
Author by
burrGGG
Updated on July 06, 2022Comments
-
burrGGG almost 2 years
Has anyone else had problems with local notifications since updating to IOS 8 and Xcode 6? I have my application which was running fine and the
notification.firdate
was set from date picker and working fine,notification.alertBody
showed up fine. Now i've updated it doesn't work. I've added break points and my firedate has a value stored in it. Can anyone please help me?-
BonanzaDriver over 9 yearsMake sure you're registering for local notifications (this is mandatory), then implement the proper delegate callbacks. There are a boat load of changes in iOS8 ... highly recommend you check out the WWDC videos.
-
-
burrGGG over 9 yearsThank you for your response. I've not used swift, will this work in my AppDelegate.m file?
-
burrGGG over 9 yearsit worked, was looking at the link you sent. Thank you for your help
-
X.Y. over 6 yearsI've been searching why the notification was failing... this is the answer!