Background mode not working with iOS13

I was happy with building app on PhoneGap and it was working very smooth for me. Now that apache PhoneGap has stopped giving support and apple is not accepting apps build with SDK <13, I had no another choice to change my environment from ionic cordova to ionic capacitor.

Upgrade works well. I’ve successfully upgraded from ionic v4 to ionic v5 using Angular 8. Background mode cordova plugin with ionic capacitor music control not working as expected. It plays the music in background and stopped after playing two music files.

Is this issue something related to audio session that we create when media creates. If so, how could I make it active all the time in background.

My local environment info is:

Angular CLI: 8.0.0
Node: 10.19.0
OS: darwin x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0 (cli-only)
@angular-devkit/build-optimizer   0.0.35
@angular-devkit/core              9.1.7
@angular-devkit/schematics        9.1.7
@angular/http                     7.2.16
@schematics/angular               8.0.0 (cli-only)
@schematics/update                0.800.0 (cli-only)
rxjs                              6.4.0
typescript                        3.5.3
webpack                           3.12.0
    

Hello, I am wondering if you were ever able to resolve this?

I have a html

This is for iOS. I have gone into xcode / signing & capabilities / background modes.

It doesn’t seem to matter what I check or uncheck. Once I do a build and test the audio always stops after about :30 seconds once I am in background mode.

I had to switch back to CORDOVA plugin to make it work. I was trying to make it work with capacitor background plugin which was not stable at that time and causing a lot of trouble in my use case. It works for me with https://www.npmjs.com/package/cordova-plugin-background-mode-fixed: “^0.7.8” version and “@ionic-native/background-mode”: “^4.20.0”,

Thanks for the reply. Unfortunately the following error is still thrown: [ProcessSuspension] Background task expired while holding WebKit ProcessAssertion

I tried it with both cordova-plugin-background-mode and cordova-plugin-background-mode-fixed both installed and separately as well. Either way the error was still thrown and the audio stopped playing after :30 seconds.

This looks like an issue with iOS 13 and above. And currently there doesn’t appear to be any work around. Audio playing in the background is an essential function to our App since we are a streaming music player.

If you have any suggestions for playing audio in the background on a Ionic Capacitor/Cordova App i’m up for any suggestions.

Thanks for your previous help.

What music control plugin are you using for it? We modified some fixes and used https://github.com/Sunilchhipa/cordova-music-controls-plugin. Try this and see if that works ?

The original repo who fixed iOS13 issue is https://github.com/yoojene/cordova-music-controls