Giter Club home page Giter Club logo

Comments (16)

janpio avatar janpio commented on June 25, 2024 1

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.

Siva021 avatar Siva021 commented on June 25, 2024

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.

anaaChacon avatar anaaChacon commented on June 25, 2024

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.

petver avatar petver commented on June 25, 2024

I have the same problem (using ionic 4). Is there a solution for this?

from cordova-plugin-network-information.

bryplano avatar bryplano commented on June 25, 2024

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.

rricamar avatar rricamar commented on June 25, 2024

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.

halindrome avatar halindrome commented on June 25, 2024

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.

PieterVanPoyer avatar PieterVanPoyer commented on June 25, 2024

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.

PieterVanPoyer avatar PieterVanPoyer commented on June 25, 2024

@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.

halindrome avatar halindrome commented on June 25, 2024

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.

PieterVanPoyer avatar PieterVanPoyer commented on June 25, 2024

Just to know, did this work before the 2.0.2 release?

from cordova-plugin-network-information.

englund avatar englund commented on June 25, 2024

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.

PieterVanPoyer avatar PieterVanPoyer commented on June 25, 2024

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.

englund avatar englund commented on June 25, 2024

@PieterVanPoyer So data saver (Connections > Data usage > Data saver) is a setting in Android.

from cordova-plugin-network-information.

PieterVanPoyer avatar PieterVanPoyer commented on June 25, 2024

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.

PieterVanPoyer avatar PieterVanPoyer commented on June 25, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.