From a08865467dbebfa8cab5a3117fb4150918b590ab Mon Sep 17 00:00:00 2001 From: umasoodch Date: Mon, 21 Dec 2020 15:45:22 +0300 Subject: [PATCH] added different plugin location for ios --- .../attend-services/attend-scan.service.ts | 24 ++++++++++++------- Mohem/src/app/home/home.page.ts | 24 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts index 85b79181..8dc6b1ff 100644 --- a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts +++ b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts @@ -56,8 +56,8 @@ export class AttendScanService { this.permissions.requestLocationAutherization().then(granted => { this.location = granted as boolean; if (this.location) { - this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { - if (this.platform.is('android')) { + if (this.platform.is('android')) { + this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { if (resp && (resp.latitude && resp.longitude)) { if (resp.isFromMockProvider || resp.mockLocationsEnabled) { this.isFakeLocationUsed = true; @@ -65,19 +65,25 @@ export class AttendScanService { this.lat = resp.latitude; this.longt = resp.longitude; this.attendance(); + } else { + this.common.presentAlert(this.ts.trPK('home', 'position-error')); } - } else { - if (resp && (resp.latitude && resp.longitude)) { - this.lat = resp.latitude; - this.longt = resp.longitude; + }, (error) => { + this.common.presentAlert(this.ts.trPK('home', 'position-error')); + }); + } else { + this.geolocation.getCurrentPosition({maximumAge: 3000, timeout: 10000, enableHighAccuracy: true}).then(resp => { + if(resp && resp.coords.latitude && resp.coords.longitude) { + this.lat = resp.coords.latitude; + this.longt = resp.coords.longitude; this.attendance(); } else { this.common.presentAlert(this.ts.trPK('home', 'position-error')); } - } - }, (error) => { + }).catch(error => { this.common.presentAlert(this.ts.trPK('home', 'position-error')); - }); + }); + } } else { return false; } diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 511c45d6..e1733fd4 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -245,8 +245,8 @@ export class HomePage implements OnInit { this.permissions.requestLocationAutherization().then(granted => { this.location = granted as boolean; if (this.location) { - this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { - if (this.platform.is('android')) { + if (this.platform.is('android')) { + this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { if (resp && (resp.latitude && resp.longitude)) { if (resp.isFromMockProvider || resp.mockLocationsEnabled) { this.isFakeLocationUsed = true; @@ -254,19 +254,25 @@ export class HomePage implements OnInit { this.lat = resp.latitude; this.longt = resp.longitude; this.attendance(); + } else { + this.common.presentAlert(this.ts.trPK('home', 'position-error')); } - } else { - if (resp && (resp.latitude && resp.longitude)) { - this.lat = resp.latitude; - this.longt = resp.longitude; + }, (error) => { + this.common.presentAlert(this.ts.trPK('home', 'position-error')); + }); + } else { + this.geolocation.getCurrentPosition({maximumAge: 3000, timeout: 10000, enableHighAccuracy: true}).then(resp => { + if(resp && resp.coords.latitude && resp.coords.longitude) { + this.lat = resp.coords.latitude; + this.longt = resp.coords.longitude; this.attendance(); } else { this.common.presentAlert(this.ts.trPK('home', 'position-error')); } - } - }, (error) => { + }).catch(error => { this.common.presentAlert(this.ts.trPK('home', 'position-error')); - }); + }); + } } else { return false; }