Quickly exit Ionic 2 app with hardware back button during splash screen



We’re building an Ionic 2 (final version) app that uses the following splash screen preferences:

  <preference name="SplashScreenDelay" value="20000"/>
  <preference name="SplashMaintainAspectRatio" value="true"/>
  <preference name="FadeSplashScreen" value="true"/>
  <preference name="FadeSplashScreenDuration" value="500"/>
  <preference name="AutoHideSplashScreen" value="true"/>
  <preference name="ShowSplashScreenSpinner" value="false"/>
  <preference name="SplashScreenBackgroundColor" value="false"/>
  <preference name="SplashShowOnlyFirstTime" value="false"/>
  <preference name="SplashScreen" value="screen"/>

We want the app to exit immediately when the hardware back button is pressed during loading. Eg when a user opened our app by accident. Is this possible?

Right now we have to wait for the app to load completely to the welcome screen. From then on, we can exit the app using the back button. For this to work, we used the solution explained here.

Ionic info:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.8
Node Version: v6.9.5
Xcode version: Not installed


I don’t have first hand knowledge of this, but I assume Ionic only can handle the back button when the app is done loading. To handle this earlier would probably require native code that is invoked even before Ionic is loaded.