Comments (16)
Yes, #74 is part of 2.0.2: https://github.com/apache/cordova-plugin-network-information/blob/master/RELEASENOTES.md#202-jun-19-2019
from cordova-plugin-network-information.
Yeah, I am also experiencing the same, i am getting network type none when app is idle for more than 20mins in the background. After reopening the app or changing to Airplane mode network working fine.. Seems like this issue is occurring to ionic latest
from cordova-plugin-network-information.
the solution that it poses @PieterVanPoyer has solved the problem for me pm android, but in them there is iOS no solution, at the moment I am satisfied.
from cordova-plugin-network-information.
I have the same problem (using ionic 4). Is there a solution for this?
from cordova-plugin-network-information.
Looks like there is a PR to fix this on Android per annaChacon's comment (it just hasn't been merged): #74
No idea about the status of the problem on iOS.
from cordova-plugin-network-information.
Hi ✋ ,
The PR has been merged, you can now install the plugin with:
cordova plugin add https://github.com/apache/cordova-plugin-network-information#master --force
in order to have the last version, while the team make a release
PS: As long as I know, I couldn't reproduce this issue on iOS. Only on Android 🤔
from cordova-plugin-network-information.
Was this merged into 2.0.2? And a related item - I don't seem to get events when the app is in the background. Is that addressed with this PR too?
from cordova-plugin-network-information.
Hello,
The #74 does not solve the network change trigger when the app is idle (or in the background) for android.
So, it does not solve this issue.
The Pull Request solves that the networkinfo is not reliable when the app is in the foreground.
Tries to solve issue-64
The plugin uses (before the PR and after the PR) the android BroadcastReceiver.
Android can stop the listeners on the BroadcastReceivers to save battery power when the app becomes idle.
To solve this the android - plugin should be rewritten and use the JobScheduler API (min-SDK Lollipop). (see: https://developer.android.com/reference/android/app/job/JobScheduler.html and https://medium.com/@iiro.krankka/its-time-to-kiss-goodbye-to-your-implicit-broadcastreceivers-eefafd9f4f8a)
But that should be another pull request.
Kind regards,
PIV
from cordova-plugin-network-information.
@halindrome in our company we do not rely on the 'offline' and 'online' events.
In our project, we allways check the navigator.connection.type before every api call.
const networkState = navigator.connection.type;
if (networkState === 'none') {
console.log('We are offline');
} else {
console.log('We are online');
}
As an addition on my previous comment, in my opinion the javascript part of an app can go idle too when android decides to save battery and when the app is in the background.
What is the use case for you to receive these events while the app is in the background?
Can the 'type' - property check solve your problem?
If not, provide a use case and maybe someone can start building a solution.
Kind regards,
PIV
from cordova-plugin-network-information.
Our application does a lot of things while the app is in the background. In general, on Android, these are successful. Even when the app is running javascript tasks those work in the background most of the time. I was relying upon this plugin (which has a non-JS component) to deliver events when the network changes state.
One of the things that is unique about our application is that it prefers to talk to a local gateway on a local network. A specialized appliance we supply to our customers. In many environments, the devices on which our application is installed do not even have access to the internet (and are not cellular or do not have their cellular data enabled). In these cases, especially when the WiFi support in the environment is uneven, we see a lot of network problems. Our application is designed to work around these dropouts by queueing messages and resending them when the network becomes available.
I will see what I can do with the navigator.connection.type
setting. I suppose a combination of this and a careful check of the devices IP address would help the application understand if it had changed networks or something. This is a common event in our application, and when it happens we need to search for a gateway again since this may have changed (a separate gateway on each subnet, for example).
Anyway, thanks for the pointer!
[edit] I attempted to rely upon this property of the navigator object. Under cordova (under ionic 4) the state of the navigator.connection.type property is not updated when the app is in the background either. So the various services we have running continue to attempt to talk to the network even when it is disconnected. Now, I could look at the response of a network request and realize that we have lost connection and act upon that, but I am surprised that this property is not being updated. Is there something we need to do to ensure that it reflects the reality of the device's environment?
from cordova-plugin-network-information.
Just to know, did this work before the 2.0.2 release?
from cordova-plugin-network-information.
We have the same issue when the data saver is on in Android. We have these problems both in version ^1.3.4 and 2.0.2.
from cordova-plugin-network-information.
Hey,
Do you mean you have a problem with saving data when the app is idle or in the background?
Is it possible for you to check version 2.0.1?
Does the problem occur in that specific version.
Kind regards,
PIV
from cordova-plugin-network-information.
@PieterVanPoyer So data saver (Connections > Data usage > Data saver) is a setting in Android.
from cordova-plugin-network-information.
Hey Englund,
Thanks for the info. I wasn't aware of the android Data Saver functionality.
This thread is becoming a bit complicated and multithreaded.
Maybe it is a good idea, to make a seperate issue for the Data Saver <-> Network information bug.
With steps to reproduce and so.
Then we are able to fix halindromes problem here, and address the Data Saver bug in another issue.
Kind regards,
Pieter
from cordova-plugin-network-information.
@anaaChacon Hey. Is the original issue still occuring? If not, can you close this issue? Kind regards.
from cordova-plugin-network-information.
Related Issues (20)
- core.js:6014 ERROR RangeError: Maximum call stack size exceeded HOT 2
- bug: 'onConnect' does not work as expected HOT 10
- Refactor eslint to use cordova-eslint HOT 1
- Drop support for node < 10. HOT 1
- Version 2.0.2 from npmjs is crashing some devices with Android 10, on startup. HOT 9
- 5G detection HOT 13
- Correct network detection API calls deprecated on Android and iOS HOT 2
- network.connection.type is giving value as unknown in case of IOS 14 HOT 2
- Under no network conditions, start the App HOT 1
- What exactly is triggering online/offline events? HOT 2
- How to install specific version? HOT 2
- what 's new in version 3.0 ? should I need to update? HOT 1
- Issue with Ionic-native/network onConnect() on upgrade to Angular 10 HOT 1
- network.type is set to 'wifi' even when iPad Air is set to flight modus or when I am turning off WiFi
- Wrong typing for Connection
- 5G detect support HOT 4
- Network Up and Down Speed in android
- Navigator.connection support
- #throwInvalidProviderError HOT 1
- Adding this plugin breaks the build HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-network-information.