Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to programmatically restart an Ionic app?

I would like to reboot my Ionic app programmatically.

I found solutions to only reload the current view like location.reload(), but I would like the app the re-run the app.js, both for iOS and Android.

like image 625
Louis Avatar asked Oct 26 '25 00:10

Louis


2 Answers

I wouldn't recomend going with that approach, in single page apps always try to have a system to reset the data, cache, history, etc. and then go to the initial state, instead of forcing to refresh de webUI. Ionic has a lot of features to help you accomplish that.

like image 64
Hiraqui Avatar answered Oct 28 '25 18:10

Hiraqui


Try this solution

var initialHref = window.location.href;
navigator.splashscreen.show();
// Reload original app url (ie your index.html file)
window.location = initialHref;
navigator.splashscreen.hide();

or you can hide your splash screen app.js inside

.run(function(){
  $ionicPlatform.ready(function () {
          if (cordova.platformId === 'ios' && window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);
        }
        if (window.StatusBar) {      
            StatusBar.styleDefault();
        }
   navigator.splashscreen.hide();
})
like image 35
Pritish Avatar answered Oct 28 '25 16:10

Pritish