跳转到主要内容
PRODUCT DOCUMENTS

快速找到所需文档,高效完成接入与排障

浏览产品文档与友盟 Skill,展开目录并阅读正文。

如何自定义推送声音?

自定义推送声音有以下几点要求:

  1. 注册时打开了声音提示选项。

  2. 项目中包含声音的资源文件。

  3. 声音资源文件必须为Linear PCM、MA4 (IMA/ADPCM)、µLaw、aLaw这4种格式之一。

  4. 后台推送必须包含sound参数,且value必须为资源名。

  5. 资源文件的声音长度小于30s,如果超过限定,会用默认声音来播放。

  6. 设备声音打开

声音格式转换:

您可以使用该afconvert工具来转换声音。例如,要将16位线性PCM系统声音Submarine.aiff转换为CAF文件中的IMA4音频,请在Terminal应用程序中使用以下命令:

afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v

官方文档:

Local and remote notifications can specify custom alert sounds to be played when the notification is delivered. You can package the audio data in an aiff, wav, or caf file. Because they are played by the system-sound facility, custom sounds must be in one of the following audio data formats:Linear PCMMA4 (IMA/ADPCM)µLawaLawPlace custom sound files in your app bundle or in the Library/Sounds folder of your app’s container directory. Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.You can use the afconvert tool to convert sounds. For example, to convert the 16-bit linear PCM system sound Submarine.aiff to IMA4 audio in a CAF file, use the following command in the Terminal app:afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v