Custom iOS push notification sound

梦想与她 提交于 2019-12-31 09:05:07

问题


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?

The code is like this

{
    "aps": {
        "badge": 10,
        "alert": "Hello",
        "sound": "sound.mp3"
    }
}

Nithin


回答1:


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.

It doesn't say anything about MP3s. I've used aif files which worked. I'd stick to what Apple specifies.




回答2:


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"



来源:https://stackoverflow.com/questions/10107556/custom-ios-push-notification-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!