“尝试安排本地通知UIConcreteLocalNotification:声音但未获得用户播放声音的许可”
- (void)registerForRemoteNotifications
{
if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
// iOS 8 Notifications
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeSound|UIUserNotificationTypeBadge) categories:nil]];
} else{
// iOS < 8 Notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIUserNotificationTypeAlert)];
}
}
//added for ios8
- (void)successfullyRegisteredUserNotificationSettings
{
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
我遵循stackoverflow中其他用户的指南,为ios8使用registerUserNotificationSettings。在调用该函数后,我等待AppDelegate中的回调:
- (void)application:didRegisterUserNotificationSettings:
在函数中,我调用上面的successfulRegisteredUserNotificationSettings方法来正式注册。
即使这样做,我仍然会收到错误。有人可以告诉我为什么吗?或者有没有人遇到过同样的问题?怎么解决这个问题?