Cordova-plugin-network-information problem with Inic v3

Asked

Viewed 60 times

1

I’m beginner in Ionic and I’m facing a problem, the application I’m developing uses the inappbrowser plugin to display a responsive site so far ok. I need that now when user disconnects from the internet independent if it is at the beginning of the application the application displays a message of nonexistent connection.

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.modulets.


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 {}
  • See if this video help you, in English, I don’t know English but I can see the guy programming and I think it’s what you need.

  • It’s not exactly what I need but it helped a lot thanks

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.