Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What exactly is triggering online/offline events? #134

Open
rolinger opened this issue Aug 5, 2021 · 2 comments
Open

What exactly is triggering online/offline events? #134

rolinger opened this issue Aug 5, 2021 · 2 comments

Comments

@rolinger
Copy link

rolinger commented Aug 5, 2021

What specifically is triggering the offline event?

What if a user is connected to wifi that has no internet? Or happens to be transitioning from Cell to Wifi....or transition between wifis. OR....the user connects to a wifi, but they must authenticate (guest internet) via a web url. In all these scenarios, the The wifi port is up...user is getting an IP address but can't get to the internet? What is being evaluated in a situation like this to determine if the user is actually online?

I have a very specific case where this has happened to a user and when launched my app went white screen. We could replicate this several times on iOS (like 1 out of every 10 times), but seemingly have never had a problem on Android (that I know of). The iOS user is def a rare case but I need to understand why this is happening so I can compensate for these scenario so my app doesn't hang on launch.

If the user loses internet while the app is launched then everything works fine.

Its only on app launch for iOS. I have document.addEventListener("online", function() {}) ; at the top of my deviceReady section and it should fire during this odd situation...but its not....and the app is hanging.

@powysm
Copy link

powysm commented Jan 10, 2022

@rolinger did you manage to get anywhere with this.
This sounds pretty much exactly what some iOS users are reporting on our app.
The only way i can recreate similar is to be connected to a wifi point w/o internet access.

I was considering treating an ios device as disconnected on app start up until it has an online event that isn't of type unknown or none, or testing this value on a timer on startup.

@rolinger
Copy link
Author

rolinger commented Jan 10, 2022

@powysm - We changed many things. In fact we completely rewrote how our app initializes, greatly simplifying it and eliminating almost all outside dependencies during start up. We use google's places/autocomplete for typing in city/town names - so this loads way before onDeviceReady() fires. If the google maps api fails to load, the call back is never called, thus something must be wrong with the internet connection. The onDeviceReady() function then looks to see if the a maps global variable is to true or false (online/offline). If true, carry on, if false, pop warning message to user and then do a deeper dive into finding out why. Since we moved to this method we have no more reports of "offline" app hanging on launch:

<script async defer 
      src="https://maps.googleapis.com/maps/api/js?key=api_key&amp;libraries=places&callback=mapsCallback" type="text/javascript">
</script>  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants