Is there a way to play a sound on receiving a (PushKit) VOIP notification? Even when in the background or the app is inactive (closed from the task manager). The sound should also override the DND and Ringer off functionality. This should be possible via the AVFoundation library as described here: Play sound on iPhone even in silent mode
At first i tried using remote push notifications, but found out this doesn't work when the app was closed from the task manager.
I already implemented the workarounds concerning ARC, as described here: AVAudioPlayer stops playing immediately with ARC but it doesn't resolve my issue. When using push notifications it's sometimes works ...
I found out that when i try to make my AudioSession active, the following error is thrown:
Error Domain=NSOSStatusErrorDomain Code=561015905 "The operation couldn\342\200’t be completed. (OSStatus error 561015905.)"
This stack overflow post says you can't play Audio while the app is in the background (How do I get my sound to play when a remote notification is received?). Is there no way to override this? And also override the ringer off and DND functionality? Because adding a sound to the notification will probably work, but it won't override the ringer off and DND.
I need this functionality for an ad-hoc enterprise application, so it won't be available in the app-store and won't need the apple app approval.