苹果推送通知iOS 8.1.3上没有播放声音

时间:2015-01-30 04:46:03

标签: ios ios8 push-notification apple-push-notifications ios8.1

我按照这个tutorial设置了所有内容,就像在iOS上接收推送通知一样。

我在Xcode中设置了didFinishLaunchingWithOptions

if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound) categories:nil]];
    [application registerForRemoteNotifications];
} else {
    [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}

我已经注册了(我能够获得deviceToken)并且我可以在发送时从推送通知中获取消息,问题是我无法播放任何通知声音,我的pusher.php是这样的:

$body['aps'] = array(
    'alert' => $message,
    'sound' => "default" 
    );

我使用的是iOS 8.1.3

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,好像下面的代码已经过时了:

if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound |
                                                                                                UIUserNotificationTypeAlert |
                                                                                                UIUserNotificationTypeBadge) categories:nil]];
    [application registerForRemoteNotifications];
}
else
{
    [application registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}

if (application) {

    application.applicationIconBadgeNumber = 0;

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|
                                                       UIUserNotificationTypeBadge|
                                                       UIUserNotificationTypeSound categories:nil]];
    }
}
return YES;}

因为我只在App中收到本地通知。即使在将正确的证书提交给此之后。 到目前为止,我还没有找到任何帮助,所以最后通过电子邮件向Apple开发者技术支持部门发送了相关信息。

相关问题