I'm a beginner in ionic and I'm facing a problem, the application I'm developing uses the inappbrowser plugin to display a responsive website so everything is ok. I need now that when user disconnects from the independent internet if it is at the beginning of the application the application displays a connection message that does not exist.
ionic: 3.9.2
Home.ts
import { NavController, ToastController } from 'ionic-angular';
import { Network } from '@ionic-native/network';
import { Component , OnInit } from '@angular/core';
import { InAppBrowser , InAppBrowserOptions } from '@ionic-native/in-app-browser';
import { Subscription} from 'rxjs/Subscription';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage implements OnInit{
connected: Subscription;
disconnected: Subscription;
};
constructor(public navCtrl: NavController, private network: Network, private toast: ToastController, private iab: InAppBrowser) {}
ngOnInit()
{
const browser = this.iab.create('http://122.21.22.22:8888/xxx/mobile/index.php','_self',{location:'no'});
browser.show();
}
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { Network } from '@ionic-native/network';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
Network,
SplashScreen,
InAppBrowser,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}