Hiding content when the app isn't active

Hi,

I need our app to hide its content with a splash screen when the app isn’t directly active, ie. when f.x you double tab on the home button on IOS and it shows all the active apps.

I tried using the example code from here:
https://capacitor.ionicframework.com/docs/apis/background-task

But it seems like the BackgroundTask.beforeExit function isn’t called before the app is entirely in the background, which at that time it too late.

Any clues or pointers on how to achieve the wanted effect is greatly appreciated.

Thanks!