Reload the app


#1

Hello everybody,
I would like to restart my application after the user change the setting.
Because I load the settings on the beginning ( on the abstrat state ) I can’t redirect the him on the first/otherwise state.
Thank you for support!


#2

add a loading overlay, that hides all content --> redirect to your initial state and call $window.location.reload();. It is like a full page reload.

Loading layer is to hide some ugly effects until your app is ready again.
The splashscreen plugin can re-display the splashscreen, but this does not work on android - i think.


#3

Yes, I’ve already experimented with the reload function, but didn’t come in mind to redirect first with $state.go, and because on my state there is already the loader it works well.

Moreover inside my factory I have to use window and not $window.

thanks!


#4

I am successfully showing the splashscreen using the plugin on both Android and iOS btw.


#5

strange i tested it still a few weeks ago. What plugin did you use?


#6

Using:

cordova-plugin-splashscreen 2.1.0 "Splashscreen"

Sample code is:

            if ( navigator && navigator.splashscreen ) {
                navigator.splashscreen.show();
                $window.location.reload();
                $timeout( function () {
                    navigator.splashscreen.hide();
                }, 500 );
            } else {
                $window.location.reload();
            }

#7

Put this in your controller.js

$state.go($state.current, $stateParams, {reload: true, inherit: false});

also make sure you set cache to false in app.js


#8

Hi Everyone,

I used the same method but it didn’t work after installing the app into the real device.

Can anyone guide me please how can I reload my page from the device, not from the browser.

this.navCtrl.setRoot(TabsPage).then(() => {
setInterval(
()=>{window.location.reload();},3000
)
});

Because this code only works in Browser not in Device.

Thanks