Subscribe on Network events not work after build prod release

Hi!
i use native Network plugin in two ways

 private observeNetworkStatus() {
    this.network.onchange().subscribe((data)=>{
      console.log(data);
      if(data.type === "online"){
        this.info("SynchronizationTasksProvider is online"); // for test when start on device
        this.isNetworkConnected = true;
        this.checkNetworkConnected.next(true);
      }
      if(data.type === "offline"){
        this.isNetworkConnected = false;
        this.checkNetworkConnected.next(false);
        this.info("SynchronizationTasksProvider is offline"); // for test when start on device
      }
    })
}

and

private observeNetworkStatus() {
this.network.onConnect().subscribe(() => {
      this.info("SynchronizationTasksProvider connected is online");  // for test when start on device
      this.isNetworkConnected = true;
      this.checkNetworkConnected.next(true);
    }, error => {
      console.error(error)
    });

   this.network.onDisconnect().subscribe(() => {
      this.isNetworkConnected = false;
      this.checkNetworkConnected.next(false);
      this.info("SynchronizationTasksProvider connected is offline");  // for test when start on device
    }, error => console.error(error));
}

both all work fine when I test debug version. The problem occurs when I build the app using ionic cordova build android --prod --release. Then works only network.onDisconnect().subscribe. Problem occurs on Android, IOS version works fine.

Do you have any hints or advise on how to do this ?

Best Regards

1 Like