xcode 适用于 iOS 的 APNS 通知声音
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25478395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
APNS notification sound for iOS
提问by Legolas
I am having some trouble setting the message sound for my app.
我在为我的应用程序设置消息声音时遇到了一些问题。
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.
所以在服务器发送的 apns 响应中,我指定了"sound" : "default"
,一切都很好。但是,如果我设置了"sound":"chime"
, 或"sound":"note"
,它们似乎不起作用。它总是播放默认。这些是我从 iPhone -> 设置 -> 声音中看到的声音。
How can i use the "Note" as my preferred notification sound, or should i create my own sound, and add it to the bundle?
我如何使用“Note”作为我首选的通知声音,或者我应该创建自己的声音并将其添加到包中?
回答by Wayne Hartman
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:
如果要播放默认声音以外的声音,则需要将声音打包到您的包中,并在有效负载中指定声音的文件名。例如,如果我要notificationCupcake.caf
在我的应用程序中包含一个声音文件,我会在推送中包含这个 JSON 键/值对:
"sound": "notificationCupcake.caf"