<span style="font-size: 18px; font-family: Arial; line-height: 26px;">在iOS8系统开发使用本地通知时,通知无法弹出,会出现如下的提示Log:</span>
Attempting to schedule a local notification ,with an alert but haven't received permission from the user to display alerts,with a sound but haven't received permission from the user to play sounds
原因在于iOS8系统变更了注册方法,需要在ApplicationDelegate里面注册通知才可以。
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)])
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}