ryanheise / audio_session

MIT License
107 stars 68 forks source link

[iOS] Background audio not playing on iPhone 13+ #110

Closed georgidimitrovx closed 8 months ago

georgidimitrovx commented 8 months ago

When app receives push notification, it needs to play a sound. It works in foreground and background for iPhone 6s. But fails to play in background for iPhone 13.

This is how I configure the audio session:

await audioSessionIOS.configure(AudioSessionConfiguration(
    avAudioSessionCategory: AVAudioSessionCategory.playback,
    avAudioSessionMode: AVAudioSessionMode.defaultMode,
    avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.mixWithOthers));

These are the errors I'm reading in the log:

'prim' with category MediaPlayback and mode Default and mixable does not have assertions to start mixable playback
'prim'' has insufficient privileges to take control
translating CM session error
-16980 Operation denied. Cannot start playing
PlatformException(561015905, Session activation failed, null, null)

I've added the audio UIBackgroundModes in Info.plist.

Any help will be greatly appreciated since this is the main functionality of the app!

ryanheise commented 8 months ago

Hi @gotiobg , since this library just wraps the native AVAudioSession API, you might find more help by asking on StackOverflow among native iOS developers about this issue.

georgidimitrovx commented 8 months ago

Thanks for the quick reply, Ryan! I already asked on SO and was wondering if you knew something about it. I'll keep looking for a solution.

Linked question: https://stackoverflow.com/questions/77295894/background-audio-not-playing-on-iphone-13

ryanheise commented 8 months ago

I'm afraid not, StackOverflow and Apple's own forums are the best places to find help on usage of the AVAudioSession API.

Clicking your linked question, I would only suggest again that rather than limiting your audience to Flutter devs, I think you would find more help by looking to the broader iOS dev community since this is an iOS issue rather than a Flutter issue.