From b792048a8f32d3fd2c02bc3604c641aab1a4ed39 Mon Sep 17 00:00:00 2001 From: umasoodch Date: Sun, 7 Mar 2021 12:25:50 +0300 Subject: [PATCH] fixed wifi issue --- .../attendance-options.component.ts | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Mohem/src/app/home/attendance-options/attendance-options.component.ts b/Mohem/src/app/home/attendance-options/attendance-options.component.ts index 64cd12ef..e1d0054d 100644 --- a/Mohem/src/app/home/attendance-options/attendance-options.component.ts +++ b/Mohem/src/app/home/attendance-options/attendance-options.component.ts @@ -39,6 +39,8 @@ export class AttendanceOptionsComponent implements OnInit { public nfcIOSSuccess = false; public lat = 0; public longt = 0; + private ssid = CommonService.MOHEMM_WIFI_SSID; + constructor( private nfc: NFC, @@ -206,6 +208,19 @@ export class AttendanceOptionsComponent implements OnInit { } } + async verifyWIFIConfiguration() { + try { + let ssid_ = await this.wifiWizard2.getConnectedSSID(); + if(ssid_ == this.ssid){ + this.common.presentAlert(this.ts.trPK("general", "forget-wifi-connection-text")); + } else { + this.startWIFIProcedure(); + } + } catch (err) { + this.common.presentAlert(this.ts.trPK("general", "forget-wifi-connection-text")); + } + } + // Wifi Attendance public async startWifi() { const isAndroid = this.platform.is("android"); @@ -216,25 +231,24 @@ export class AttendanceOptionsComponent implements OnInit { if(!isWifiEnabled){ this.showWifiNotEnabled(); return; + } else { + this.verifyWIFIConfiguration(); } } else if(isAndroid) { let locationPermission = await this.devicePermissionsService.requestLocationAutherization(); - if (!locationPermission) { return; } if (!isWifiEnabled) { - this.wifiWizard2.setWifiEnabled(true).then(()=>{ - this.startWifi(); - }).catch((err) => { - console.debug(err); this.showWifiNotEnabled(); - }); - return; + } else { + this.startWIFIProcedure(); } } - // opening wifi dailog if all above conditions are passed (isWifiEnabled == true) + } + + async startWIFIProcedure () { let modal = await this.modalController.create({ component: WifiModalComponent, showBackdrop: true,