cordova-plugin-splashscreen
cordova-plugin-splashscreen copied to clipboard
Splash Screen show() and hide() not working on platform pause and resume
Bug Report
On platform.pause and platform.resume (<a href="https://ionicframework.com/docs/v3/api/platform/Platform/">as shown here</a>
) when I try to use splash screen show() and hide() but it does not show the splash screen, and so obviously there is nothing to hide.
Problem
Unable to use splashscreen.show() and splashscreen.hide() with platform.pause and platform.resume
What is expected to happen?
When the user presses the Overview button and the app is moved to background mode the app should only show the Splash Screen
What does actually happen?
When the user presses the Overview button and the app is moved to background mode the app shows the current content of the app
Information
Currently running the android platform, not sure if that matters.
Command or Code
ionic cordova run android -l -c --verbose;
Environment, Platform, Device
Ionic v3
Version information
Checklist
- [ x] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [x ] I included all the necessary information above
When the user presses the Overview button and the app is moved to background mode the app should only show the Splash Screen
If the app is not shown anymore, where should it "only show the Splash Screen" then? What exactly do you refer to by "Overview button" and "backgorund mode"? From the command you posted I infer you are talking about Android, correct?
Part of your explanation also uses Ionic specific code. Does your problem also exist in a plain Cordova app?
I'm seeing a similar result. I have
function onPause() { navigator.splashscreen.show();
which works fine in iOS but on Android (emulator) it doesn't show the splashscreen except momentarily when you click the app to switch back to it.
@janpio I am pretty sure the @vforvasquez has the following scenario in mind:
- the user wants to switch to another app with the "overview" button (yes, that's its name, I had to google it - https://android.stackexchange.com/questions/32697/what-is-the-offical-name-of-the-third-on-screen-button but it's also called "recent" or "tasks")
- the OS shows the list of currently open apps, including the screenshot of "our" app
- the idea is to show the splash screen instead of a true screenshot to avoid leaking sensitive information
- using
splashscreen.show()
inonPause()
does not work because the event handler is run on application resume - most likely due to thread switching
Another thread about the very same scenario is here.
It mentions an outdated plugin that achieves the result by disabling screenshots altogether which is not an optimal solution.
This is not the issue within the splashscreen plugin per se, but it's closely related and if the plugin would allow to achieve this as an option without cumbersome hacks then it would be an extremely useful feature. It seems the most complicated logic is in selecting the proper image to show (depending on resolution, orientation etc.) which the splashscreen plugin already handles very well, so any external plugin just for the onPause
screenshot would have to duplicate it -which sounds unreasonable.