In the browser on desktop this works. But if i run the app on android it doesn’t? Any idea why? Or is that actually the expected behaviour for Android? On the ios emulator it also works (with a little delay).
You will need to wait a few seconds before the connection is fully initialized and ready. From the plugin doc:
// watch network for a connection
let connectSubscription = this.network.onConnect().subscribe(() => {
console.log('network connected!');
// We just got a connection but we need to wait briefly
// before we determine the connection type. Might need to wait.
// prior to doing any api requests as well.
setTimeout(() => {
if (this.network.type === 'wifi') {
console.log('we got a wifi connection, woohoo!');
}
}, 3000);
});