iOS 推送通知的可用声音列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10709707/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:28:39  来源:igfitidea点击:

List of available sounds for iOS push notifications

iosios5push-notification

提问by Jhorra

I'm trying to change the sound for my push notifications, but I don't know what the names are to use. I want to use the "electronic" sound, but what do I put in the sound field in my payload? Is there a list of available sounds?

我正在尝试更改推送通知的声音,但我不知道要使用什么名称。我想使用“电子”声音,但我在有效载荷的声场中放了什么?有可用的声音列表吗?

采纳答案by kevboh

As stated in the docs, you can specify "default" as the value for your "sound" key in the payload to play the default sound, or the name of a sound file in your app bundle to play that sound. You'll need to prepare the soundto make sure it's in a compatible format.

文档所述,您可以将“默认”指定为负载中“声音”键的值以播放默认声音,或指定应用程序包中的声音文件名称以播放该声音。您需要准备声音以确保其格式兼容。

回答by Matt Andrzejczuk

The answer above may be wrong.

上面的答案可能是错误的。

You CAN specify a built in sound, the problem I'm looking into is figuring out all the names.

您可以指定内置声音,我正在研究的问题是找出所有名称。

This APNS Python code for example works:

此 APNS Python 代码例如有效:

APNSmessage = Message([u1.push_notification_token], sound="chime", alert=sender+" Private Messaged You: "+messagePushNotification, badge=u1.unread_badge_count, custom={'slug':slugChannel})

Notice that soundis set to chimeand not default. This works for iOS 7 and above and don't see why not that it should work for iOS 8 as well.

请注意,sound设置为chime和 not default。这适用于 iOS 7 及更高版本,不明白为什么它也适用于 iOS 8。

When I first wrote this code I just took a wild guess and entered chimewhich low and behold worked.

当我第一次编写这段代码时,我只是进行了一个疯狂的猜测,然后输入了chime哪个低和哪个有效。