自定义 iOS 推送通知声音
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10107556/
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
Custom iOS push notification sound
提问by nithinreddy
I have been facing an issue. I implemented push notification in iOS with custom sound. Its a MP3 file. It plays well when I receive a push notification in iOS 5, but in iOS4, it doesn't play any sound. Can you help me with this?
我一直面临一个问题。我在 iOS 中使用自定义声音实现了推送通知。它是一个 MP3 文件。当我在 iOS 5 中收到推送通知时,它播放得很好,但在 iOS4 中,它不播放任何声音。你能帮我解决这个问题吗?
The code is like this
代码是这样的
{
"aps": {
"badge": 10,
"alert": "Hello",
"sound": "sound.mp3"
}
}
Nithin
尼丁
回答by Inn0vative1
According to the push notification guide:
根据推送通知指南:
You can package the audio data in an aiff, wav, or caf file. Then, in Xcode, add the sound file to your project as a nonlocalized resource of the application bundle.
您可以将音频数据打包到 aiff、wav 或 caf 文件中。然后,在 Xcode 中,将声音文件作为应用程序包的非本地化资源添加到您的项目中。
It doesn't say anything about MP3s. I've used aif files which worked. I'd stick to what Apple specifies.
它没有说明任何关于 MP3 的内容。我使用了有效的 aif 文件。我会坚持苹果指定的内容。
回答by pasql
You can't play .mp3-files. However, you can convert them into .wav files here: http://media.io/(online & free). Then put the converted file in your XCode project and you can call it by specifying "sound":"sound.wav"
您不能播放 .mp3 文件。但是,您可以在此处将它们转换为 .wav 文件:http: //media.io/(在线和免费)。然后把转换后的文件放到你的XCode项目中,你可以通过指定来调用它"sound":"sound.wav"