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

Network plugin onConnect/onDisconnect not triggered #4837

Open
willyboy opened this issue Sep 21, 2024 · 1 comment
Open

Network plugin onConnect/onDisconnect not triggered #4837

willyboy opened this issue Sep 21, 2024 · 1 comment

Comments

@willyboy
Copy link

This is a clone of #4086 as it was closed "inactive" but the issue still exists. I think the API for the underlying plugin has changed to just one event "networkStatusChange". I was hoping this plugin would give me the "onDisconnect/Connect" methods for readability.

I'm submitting a ... (check one with "x")
[ x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior:
The onConnect/Disconnect subscriptions are never getting invoked when the network status changes.

Expected behavior:
The onConnect/Disconnect subscriptions should be invoked when the network status changes.

Steps to reproduce:
Simple cordova 6 app with network plugin installed can be used to reproduce the issue.

Related code:

import { Network }  from '@awesome-cordova-plugins/network/ngx';

constructor(private platform: Platform, private network: Network {
  platform.ready().then(() => {
     this.network.onDisconnect().subscribe(() => {
        console.log('>network was disconnected :-(');
     });
     this.network.onConnect().subscribe(() => {
       console.log('>network was connected :-)');
     });      
});

}
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic:

Ionic CLI : 6.18.2 (/home/elega9t/.nvm/versions/node/v14.16.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.9.3
@angular-devkit/build-angular : 12.2.16
@angular-devkit/schematics : 12.2.16
@angular/cli : 12.2.16
@ionic/angular-toolkit : 5.0.3

Capacitor:

Capacitor CLI : 3.4.3
@capacitor/android : not installed
@capacitor/core : 3.4.3
@capacitor/ios : not installed

Cordova:

Cordova CLI : 11.0.0
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)

Utility:

cordova-res : 0.15.4
native-run : 1.5.0

System:

Android SDK Tools : 26.1.1 (/home/self/Android/Sdk)
NodeJS : v14.16.0 (/home/self/.nvm/versions/node/v14.16.0/bin/node)
npm : 8.5.2
OS : Linux 5.8

@MaximBelov
Copy link
Contributor

Hi @willyboy
Awesome Cordova Plugins wraps plugin callbacks in a Promise or Observable.
The error is not related to this repository.

Maybe your issue is related to plugin itself
https://github.com/apache/cordova-plugin-network-information

Try to create a demo application without ionic or capacitor
Just Cordova + plugin

cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add ios
cordova platform add android
cordova plugin add cordova-plugin-network-information
cordova build

Good luck

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