Я следую этому учебнику и пишу в app.component.ts этот код.
export class AppComponent implements OnInit {
isConnection: boolean;
constructor() {}
ngOnInit() {
const myConnectionType = getConnectionType();
switch (myConnectionType) {
case connectionType.none:
this.isConnection= false;
dialogs.confirm({
message: "Please, check Wifi",
okButtonText: "OK",
}).then(result => {
console.log("Dialog result: " + result);
});
break;
case connectionType.wifi:
this.isConnection= true
break;
case connectionType.mobile:
this.isConnection= false;
dialogs.confirm({
message: "Please, check Wifi",
okButtonText: "OK",
}).then(result => {
console.log("Dialog result: " + result);
});
break;
case connectionType.ethernet:
this.isConnection= false;
dialogs.confirm({
message: "Please, check Wifi",
okButtonText: "OK",
}).then(result => {
console.log("Dialog result: " + result);
});
break;
default:
break;
}
}
}
Я не понимаю, почему не работает, когда я отключаю WiFi?
В app.component.html
<page-router-outlet></page-router-outlet>
В AndroidManifest / xml я положил <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Есть идеи, пожалуйста?