Lot of changes

This commit is contained in:
Eudes Inácio
2021-11-09 17:23:39 +01:00
parent 308e5b36fe
commit bef79d674b
29 changed files with 84 additions and 247 deletions
+12 -12
View File
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs'
import { Platform } from '@ionic/angular'
import { Network } from '@capacitor/network';
@Injectable({
providedIn: 'root'
@@ -9,20 +10,19 @@ import { Platform } from '@ionic/angular'
export class NetworkConnectionService {
online: boolean = true;
constructor(){}
checkOnline() {
window.addEventListener('online', (on) => {
this.online === true;
console.log('Became online');
constructor(){
Network.addListener('networkStatusChange', status => {
console.log('Network status changed', status);
});
}
checkOffline() {
window.addEventListener('offline', (off) => {
this.online === false;
console.log('Became offline')
});
}
logCurrentNetworkStatus = async () => {
const status = await Network.getStatus();
return status;
};
}