Reload an app from javascript


#1

What is the better way to “reload” an app (reset, as if you first start) from the code of my trigger.io app ?

I have tried “location.reload();”, it reload the app BUT : absolutely no network access anymore…

I don’t understand why (on Android 7.0)


#2

Just out of curiosity, what is the purpose of wanting to ‘reload’ the app? I’m fairly certain I have experienced what you are talking about, not specifically the no network issue but after say a ‘Refresh’ or ‘Hard Reload’ the app appears to loose functionality.

Have you tried maybe httpD with a set port and then the location.reload


#3

Safest way, surprisingly, is like this:

forge.reload.applyAndRestartApp(function () {});

Also see: https://trigger.io/docs/current/api/core/reload.html

Edit: The API is “polite” by design so it will still restart even if there’s nothing to apply.

There’s been very little call for this so we never bothered to break the restart portion out into its own API :slight_smile:


#4

So are you saying just to fo-trigger a reload? Will it not thrown an error if there is not downloaded reload package?


#5

A very bad reason :slight_smile: A Single Page Application in which I don’t understand a bug, that resolve only after a F5 on browser and I have a demo in 1 day. So I will look investigate after the demo.

But I was surprised to loose all the network access. Quite strange


#6

Thank’s a lot Antoine ! I didn’t think to look there.


#7

Yah, that does not seem to really make sense… so like images and the like are no longer accessible or your xhr calls wont work?


#8

I found what I think is a bug because your solution don’t work.

I can say with certitude than on Android (6 or 7, didn’t try 8),

after calling :

location.reload()

or

forge.reload.applyAndRestartApp(function () {});

then :

window.forge.is.connection.connected()

return undefined


#9

Are you calling forge.is.connection from inside the connectionStateChange listener?

i.e.

forge.event.connectionStateChange.addListener(function(e){
    if (forge.is.connection.connected()) {
        // device is connected to the Internet
    } else {
        // handle case where device does not have an Internet connection
    }
});

The results are undefined if you call it anywhere else.

See: https://trigger.io/docs/current/api/core/is.html