这是我的UILocalNotification代码:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = aNewDate;
localNotification.alertBody = alertBody;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
它从模拟器正确激发,但不是从我的iphone激发。有什么建议吗?
供参考,我在设置中检查了通知,我的应用程序没有出现在那里
答案 0 :(得分:1)
iOS 8代码:(如果定位iOS7,您必须确保不要调用这些方法......)
scheduleLocalNotification:
有一个注释:
讨论:在安排任何本地通知之前,您必须致电 让系统知道的
registerUserNotificationSettings:
方法 您计划向用户显示哪些类型的警报(如果有)。
所以...
UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge;
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];