在iOS8系统开发使用本地通知时,会出现如下的相关提示语:
1 Attempting to schedule a local notification
2 with an alert but haven't received permission from the user to display alerts
3 with a sound but haven't received permission from the user to play sounds
……
原因在于iOS8系统变更了注册方法,需要在ApplicationDelegate里面注册通知才可以,如下代码:
// iOS8注册本地通知
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)])
{
[application registerUserNotificationSettings:[UIUserNotificationSettingssettingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSoundcategories:nil]];
}