Problem with plugin cordova network Ionic V5

Now, I write code withe Network plugin and when I disconnected network in my device, i can´t see allert in console.

checkNetwork() {
let connectSubscription = this.network.onConnect().subscribe(() => {
console.log(‘Estoy con internet’);
});
let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
console.log(‘Estoy sin internet’);
});
}

The problem is that i don´t know, where i should write there code, if in the constructor, ngOinit… Beause i want when press a button check if it have connection and when no connection active background mode.

Also, I tried write a service and constructor.

Thanks.