iOS 编辑来自应用程序的推送通知声音
iOS Edit Push Notification Sound From App
我想知道是否可以通过我的应用程序存储和编辑我的推送通知声音,而不会导致我的服务器向 Apple 的服务器发送带有警报名称的推送通知请求。
有一个关于此的 Apple 文档Apple Developer Doc
准备自定义警报声音
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 PCM
MA4 (IMA/ADPCM)
µLaw
aLaw
Place 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
通知负载示例
{
"aps" : {
"alert" : "YOUR_TEXT",
"badge" : YOUR_BADGE_NUMBER,
"sound" : "YOUR_SOUND_FILE.aiff"
}
}
并且您的自定义声音文件应该在您的项目包内(即在项目层次结构内)并且在拖放时选择“如果需要复制项目”选项。
我想知道是否可以通过我的应用程序存储和编辑我的推送通知声音,而不会导致我的服务器向 Apple 的服务器发送带有警报名称的推送通知请求。
有一个关于此的 Apple 文档Apple Developer Doc
准备自定义警报声音
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 PCM MA4 (IMA/ADPCM) µLaw aLaw Place 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
通知负载示例
{
"aps" : {
"alert" : "YOUR_TEXT",
"badge" : YOUR_BADGE_NUMBER,
"sound" : "YOUR_SOUND_FILE.aiff"
}
}
并且您的自定义声音文件应该在您的项目包内(即在项目层次结构内)并且在拖放时选择“如果需要复制项目”选项。