1

I use privacy-screen plugin to hide content when app is in the background, but it shows just gray background. I need to set splashScreen instead. Any suggestions?

I tried splashScreen plugin, but it is not working for me.

Sndir_Ha
  • 11
  • 2

2 Answers2

0

I don't know if it's the best way but I think that using Capacitor appStateChange from @capacitor/app (documentation) you could show and hide a screen with your logo when app is in background or foreground.

import { App } from '@capacitor/app';

App.addListener('appStateChange', ({ isActive }) => {
  console.log('App state changed. Is active?', isActive);
  if(!isActive) showLogoScreen();
  else hideLogoScreen();
});

I hope it helps :)

Miguel
  • 188
  • 5
  • Thank you Miguel for your answer, I tried and it is not working for me, unfortunately! – Sndir_Ha Feb 14 '23 at 14:12
  • Ohhh, sorry. You can also try the library [@capacitor/splash-screen](https://capacitorjs.com/docs/apis/splash-screen) and maybe using it with `appStateChange` you can approach it. – Miguel Feb 14 '23 at 15:02
0

For iOS, I did it simply in native code: just find the "applicationWillResignActive" method in AppDelegate and insert a view on top of the window.

For Android, sadly I couldn't find a better solution. The "gray background" you described is likely the implementation of Hide screen in 'Recent Apps List', but allow screenshots

Chris.Z
  • 51
  • 5