Connection status NOT reported down if Cordova application opened with no connection
cpalanzo opened this issue · comments
Even though it says in the documentation that:
"Also, the first connection attempt (when the application is loaded for the first time) only shows the alert message on mobile (Cordova)."
This no longer appears to be true.
If have this in a Cordova app and put the device - in this case and iPad or iPhone - into "Airplane" mode to kill connectivity - there is NO error message shown.
thanks for the issue, it reminds me of something I noticed not long ago.
I will take a look into it.
Hi @255kb, ha, I just worked out we had been talking on stackoverflow about other issues. Firstly thanks for this nice looking package, suits my UI nicely.
I am a +1 on this request. IMHO the way to get round the offline message appearing every time would be to simply wait a while after startup before starting checks - an arbitrary default of say 10 secs which can be overridden by config. That would feel intuitive for the user.
Of course the best would be to wait until the app has fully loaded, but I guess that's a lot harder to work in a generic case.
Hmmm, looking back, possibly I drank too much beer at the office party ;)
I do have the same issue - no alert when opening the app on airplane mode.
What I mean is this: in v1.3.2 you fixed an issue where the alert does not show at startup. I had assumed that this fix caused the airplane mode issue by waiting until the app is online before enabling the alert - which for airplane mode would be never. In which case, doing a configurable 10 sec wait before enabling alerts, instead of waiting for being online first would be a better solution for me at least... sorry I haven't had a chance to look through the package code to see if this is right, just a wild guess on a solution...
Ah, seeing the code, indeed that's how it works. So my suggestion would be to use a timeout to set firstConnection to true after a configurable (default 10 sec) time. Then it works well both if the app starts up online, and also if it starts offline.
I guess there might be apps that want a fully offline mode without the alert coming up, so a config value of 0="never show" would be handy.
+1
@255kb is there any progress on this?
Sorry for the silence of the last months, time for side projects is really hard to find. But I will try to have a look at this this week end
I published a new version (1.5.0) correcting this problem. Following @Alveoli suggestion the package checks the connection from the first time (it was previously skipping the first connection), but with a little more delay before reporting a connection down (from the third attempt instead of the second).
From my test it works well.
Let me know if this is not working for you.
Thanks Guillaume ( @255kb ) it seems to be working nicely.