Reputation: 1520
here's my UILocalNotification code:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = aNewDate;
localNotification.alertBody = alertBody;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
it fires correctly from the simulator, but not from my iphone. any suggestions?
for reference, i checked notifications in settings and my app doesnt appear there
Upvotes: 0
Views: 93
Reputation: 14549
iOS 8 code: (if targeting iOS7 you will have to make sure you don't call these methods...)
scheduleLocalNotification:
has a note:
Discussion: Prior to scheduling any local notifications, you must call the
registerUserNotificationSettings:
method to let the system know what types of alerts, if any, you plan to display to the user.
so...
UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge;
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
Upvotes: 1