apache / cordova-plugin-network-information

Apache Cordova Network Information Plugin
https://cordova.apache.org/
Apache License 2.0
464 stars 321 forks source link

Online not firing on iOS #72

Open danfleck opened 6 years ago

danfleck commented 6 years ago

Online event isn't firing on iOS.

Environment: iOS iPhone 5 emulator. iOS version: 10.3.1 Also tried same thing on iOS iPhone 6s emulator with iOS 11.4 On physical iPhone 5 with iOS 11.4.1 everything seems to work. Does the plugin have problems in the emulator?

cordova platforms   iOS 4.5.5

Steps to repeat: cordova create test cordova platforms add ios@latest Add this to index.js:

onDeviceReady: function() {
        this.receivedEvent('deviceready');

        document.addEventListener("online", () => { 
        console.log("ONLINE")
        }, false);
        document.addEventListener("offline", () => { 
        console.log("OFFLINE")
        }, false);
    },

On the machine running the emulator turn off all network access.

At this point "OFFLINE" prints (good!)

Turn on network access on the computer running the emulator.

Expect to see "ONLINE" but I see nothing.

imgoddqp commented 5 years ago

have this issue been resolved?

darkmoment0088 commented 5 years ago

I have the same setup and issue, I found out that online event will be fired if you switch device to background and foreground.

dmitry-stepanenko commented 5 years ago

Have the same issue. Workaround by @darkmoment0088 works for me.

darkmoment0088 commented 5 years ago

Have the same issue. Workaround by @darkmoment0088 works for me.

on some research, i found that it is only happened on certain iOS version. on iPad. it does not happen on iOS12 and above.

hope this information is helpful for you.