Reputation: 53
I have implemented AVAudioPlayer on didReceiveRemoteNotification fetchCompletionHandler Where it plays audio on receiving Push Notification.
However my app is rejected saying
Your app declares support for audio in the UIBackgroundModes key in your Info.plist but did not include features that require persistent audio.
Next Steps
The audio key is intended for use by apps that provide audible content to the user while in the background, such as music player or streaming audio apps. Please revise your app to provide audible content to the user while the app is in the background or remove the "audio" setting from the UIBackgroundModes key.
I have found apple doesn’t allow this.. as default it will allow 30seconds to lay sound on receiving notification..I Need to be play sound continuously until user opens the app .Is their any solution for it?
Upvotes: 2
Views: 2103
Reputation: 3708
You don't need to use background audio play.
For playing or performing any task in background you can use background task with expiration handler : https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started
Implement UNUserNotifications for local notifications : https://useyourloaf.com/blog/local-notifications-with-ios-10/
Use NSTimer to perform sound task and show local notifications for 30 sec or 1 minute depend on your requirement.
https://github.com/TUNER88/iOSSystemSoundsLibrary: for system sounds that you play in background
Upvotes: 0