@SpookieUkie wrote:
For some reason, if I reload a page that is already offline in Google Chrome, the Network.getStatus() is telling me it is online. It will actually fire the connected status change 3 times to online, offline and back online. When I move it back online, it is still online and no event is fired.
If I load the page online, then change the status to offline, it update properly
Any though on this? Thanks
Here is the code for the service:
constructor(
public storage: Storage,
private httpClient: HttpClient,
private sharedService: SharedService,
private loadingController: LoadingController) {this.getStatus(); if (this.handler === undefined) { this.handler = Network.addListener('networkStatusChange', (status) => { console.log('Network status changed! ', status); const oldStatus = this.status; this.status = status; if (this.status !== null && this.status.connected && !oldStatus.connected && oldStatus !== null) { this.saveCachedData(); } this.status = status; if (!this.status.connected) { this.sharedService.showNotification('Network connection has terminated.', 'danger', 5000); } else { try { this.loaderElement.dismiss(); } catch (error) { } } }); }
}
public async getStatus() {
this.status = await Network.getStatus();
}
Posts: 1
Participants: 1