我正在寻找在 iOS 设备上收到推送通知时播放自定义声音的方法。我知道在 iOS 上声音文件应该嵌入到应用程序包中。但我想要实现的是播放远程服务器上可用的声音。不幸的是,听起来我的应用程序的数据库太大了,无法将其全部捆绑到应用程序中。
我知道这不是那么简单,但我脑子里有一些想法:
- 播放类似 Endomondo 的声音,同时跟踪我们的锻炼情况。但我猜测它与定位 (GPS) 信号的一些后台任务有关。
- 像 Spotify 一样播放声音。设备收到通知后,只需通过流媒体播放音频播放器中的音乐即可。
- 将音乐文件下载到本地存储并像附加到应用程序包一样播放。但是是否有可能以这种方式(远程)更新应用程序包?
我的想法是否正确?或者完全确定在 iOS 上我们无法通过推送通知播放远程声音?
最佳答案
回答你的问题
- 不,不可能在远程通知上播放声音,除非你在主包上有它 check docs here
For remote notifications in iOS, you can specify a custom sound that iOS plays when it presents a local or remote notification for an application. The sound files must be in the main bundle of the client application.
- 即使您在主包中添加声音文件,该文件也不能超过 30 秒,因此 2 也是不可能的
Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.
- 不,一旦应用发布,就不可能以任何方式更新主包,除非您发布更新
关于ios - iOS 推送通知的远程声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25877904/