的iOS 8.1推送通知没有声音 [英] iOS 8.1 Push Notification No Sound

查看:314
本文介绍了的iOS 8.1推送通知没有声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该设备是iOS 8.1中运行

The device is running on iOS 8.1

我用x code 6.1编译应用程序。

I'm using xCode 6.1 to compile the app.

这是code,为推动注册

This is the code to register for push

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [application registerForRemoteNotifications];
}
else
{
    [application registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

它正常工作与服务器应用程序寄存器。

It works fine as the app registers with the server.

的PEM文件也做得正确,我可以送一推,使用沙箱APN我的设备。

The PEM files are also done correctly as I can send a push to my device using sandbox APN.

在打印我的JSON有效载荷从 didReceiveRemoteNotification 我得到这样的:

When I print my JSON payload from didReceiveRemoteNotification I get this:

{
    aps =     {
        alert = "Test Push Message";
    };
}

问题是,当我收到我的push(即使在设备设置为大声)不能播放任何声音。

The issue is when I receive my push (even when the device is set to loud) it doesn't play no sound.

这是我的知识,如果你不指定一个声音在JSON有效载荷应该发挥默认的操作系统声音。

From my knowledge if you don't specify a sound in the JSON payload it should play the default OS sound.

在手机上我的应用程序的通知设置的声音是默认启用的,因为当我登记我指定 UIUserNotificationTypeSound

In my App notification settings on the phone the sound is enabled by default because when I register I specify UIUserNotificationTypeSound.

任何人都遇到过这个问题?

Anyone else come across this issue?

推荐答案

据<一个href=\"https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1\">Apple's 你需要指定文档默认如果你想默认的推送通知要播放:

According to Apple's documentation you need to specify default if you want to the default push notification to be played:

在应用程序中捆绑了声音文件的名称。此文件中的声音
  演奏作为警报。如果声音文件不存​​在或默认为
  指定为值,默认警报声音被播放。音频
  必须在音频数据格式与兼容的一
  系统声音;见preparing自定义警告声音的详细信息。

The name of a sound file in the app bundle. The sound in this file is played as an alert. If the sound file doesn’t exist or default is specified as the value, the default alert sound is played. The audio must be in one of the audio data formats that are compatible with system sounds; see Preparing Custom Alert Sounds for details.

最后的JSON输出:

{
    "aps" :     {
        "alert" : "Test Push Message",
        "sound" : "default"
    };
}

这篇关于的iOS 8.1推送通知没有声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆