This commit is contained in:
ivan gomes
2021-11-22 15:26:04 +01:00
parent b11b2bcb31
commit 674f3636b3
9 changed files with 78 additions and 45 deletions
+15 -1
View File
@@ -9,6 +9,7 @@ import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'
const moment = _rollupMoment || _moment;
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
@@ -39,7 +40,8 @@ export class AppComponent {
/* private splashScreen: SplashScreen, */
private statusBar: StatusBar,
private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) {
this.initializeApp();
}
@@ -65,6 +67,18 @@ export class AppComponent {
console.log("Error creating local database: ", error)
}
}
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
}
});
window.addEventListener('offline', () => {
console.log('Became offline')
this.backgroundservice.offline()
});
});
}