【发布时间】:2015-01-14 09:47:04
【问题描述】:
这是注册推送的代码
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
[application registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
当应用程序向服务器注册时,它工作正常。
PEM 文件也正确完成,因为我可以使用沙盒 APNS 向我的设备发送推送。
当我从 didReceiveRemoteNotification 打印我的 JSON 有效负载时,我得到了这个:
{
aps = {
alert = "Test Push Message";
};
}
问题是当我收到推送时(即使设备设置为响亮),它也不会播放声音。
据我所知,如果您没有在 JSON 有效负载中指定声音,它应该播放默认的操作系统声音。
在我的手机应用通知设置中,默认情况下会启用声音,因为我在注册时指定了UIUserNotificationTypeSound。
还有其他人遇到过这个问题吗?
【问题讨论】:
-
你不应该检测类似的版本:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0),而是检查类是否可用:if ([UIUserNotificationSettings class])
标签: ios audio push-notification