1
votes

I'm looking for the way to play custom sound while push notification is received on iOS device. I know that on iOS sound file should be embeded into application bundle. But what I want to achieve is playing sound which is available on remote server. Unfortunately sounds database for my app is to big to bundle it all to the app.

I know it's not that straightforward but I have a few ideas in my head:

  1. Playing sound like Endomondo, while it's tracking our workout. But I'm guessing that it's connected with some background tasks for location (GPS) signal.
  2. Playing sound like i.e. Spotify does. After device receives notification just play music in audio player via streaming.
  3. Download music file into local storage and play it like it would be attached to application bundle. But is it possible to update application bundle in that way (remotely)?

Does any of my ideas is right way? Or it's totally sure that on iOS we cannot play remote sound with push notification?

2

2 Answers

2
votes

To answer your questions

  1. No it is not possible to play a sound on remote notification unless you have it on Main bundle 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.

  1. Even if you add a sound file on your main bundle , that file can not be longer than 30 seconds , so 2 is also not possible

Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.

  1. No it is not possible to update Main bundle in any manner once app is released unless you release a Update
0
votes

You can indeed download a remote sound to local storage, specifically, the /Library/Sounds folder of your app. See this apple doc.

My answer here copy a file from system into my app's directory instead of from remote server, but the concept applies as well.