本地通知:即使在注册UIUserNotificationTypeSound之后也无权播放声音

时间:2014-10-15 09:40:00

标签: objective-c push-notification ios8 xcode6 uilocalnotification

“尝试安排本地通知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方法来正式注册。

即使这样做,我仍然会收到错误。有人可以告诉我为什么吗?或者有没有人遇到过同样的问题?怎么解决这个问题?

0 个答案:

没有答案