适用于 iOS 的 APNS 通知声音 [英] APNS notification sound for iOS

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

问题描述

我在为我的应用设置消息声音时遇到了一些问题.

I am having some trouble setting the message sound for my app.

所以在服务器发送的 apns 响应中,我指定了 "sound" : "default",一切都很好.但是,如果我设置了 "sound":"chime""sound":"note",它们似乎不起作用.它总是播放默认.这些是我从 iPhone 中看到的声音 -> 设置 -> 声音.

So in the apns response sent by the server, I specify "sound" : "default", and its all good. But if I set the "sound":"chime", or "sound":"note", they dont seem to work. It always plays Default. Those are sounds i see form iPhone -> settings -> Sounds.

我如何使用Note"作为我首选的通知声音,或者我应该创建自己的声音并将其添加到捆绑包中?

How can i use the "Note" as my preferred notification sound, or should i create my own sound, and add it to the bundle?

推荐答案

如果要播放默认声音以外的声音,则需要将声音打包到您的 bundle 中,并在其中指定声音的文件名有效载荷.例如,如果我要在我的应用程序中包含一个名为 notificationCupcake.caf 的声音文件,我会在推送中包含这个 JSON 键/值对:

If you want to play a sound other than the default one, you will need to package the sound in your bundle and specify the file name of the sound in the payload. For example, if I were to include a sound file called notificationCupcake.caf in my app, I would include this JSON key/value pair in the push:

 "sound": "notificationCupcake.caf"

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

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