Our app use notification service extension to play custom audio. It works fine before iOS12.0(include 12.0).
But when i upgrade to 12.1, and found it can't play custom audio in background.
1. We found it report error when call [AVAudioSession setActive:true error:&err], the error info is
Error Domain=NSOSStatusErrorDomain Code=561015905 "(null)"
https://developer.apple.com/documentation/avfoundation/avaudiosession/errorcode/cannotstartplaying
I'm sure our main app has the background mode property for audio.
2. When we use AVAssetExportSession to export AVMutableComposition to output an new m4a file, it report error too.
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16980), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x10550bba0 {Error Domain=NSOSStatusErrorDomain Code=-16980 "(null)"}}
3. If we use AVAudioPlayer to paly an mp3 file, it failed.
Can anyone help me?
Most extensions are not allowed to activate an audio session, and so cannot play audio or use speech synthesis. This wasn't being enforced consistently prior to iOS 12.1, but now it is.
Some extensions (such as notification content extensions) present UI to the user, and those are allowed to activate an audio session.
Background modes in info.plist are not allowed for app extensions (and will get your app rejected by App Review)