Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio background mode not working with react-native-track-player

I'm currently use react-native-track-player version 1.1.8 to stream audio from Internet. It works fine (react-native version 0.61.4)

I would like now to use it in background mode, to be able to continue to listen to radio if my app is in background mode.

I followed instructions from https://react-native-kit.github.io/react-native-track-player/background/, so add capabilities in xCode, which should be enough.

It doesn't work so I also add

TrackPlayer.updateOptions({
    stopWithApp: false
});

but stil not working on real device on iOS 13. I can see this message when the app goes background :

Can't end BackgroundTask: no background task exists with identifier 1 (0x1),
or it may have already been ended. 
Break in UIApplicationEndBackgroundTaskError() to debug.

But breakpoint does not give additional informations.

Any idea or experience with this audio library in background mode? Thanks!

like image 392
Eric Avatar asked Oct 24 '25 05:10

Eric


1 Answers

It seems that the background permissions structure in iOS 13 changed.

I had the same issue and solved it by:

  1. Ticking Background processing as well in Background modes: enter image description here
  2. Adding Permitted background task scheduler identifiers to my app target at Xcode (info tab) with my app identifier as value.
like image 54
guy Avatar answered Oct 25 '25 18:10

guy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!