commented background geolocation plugin code

MOHEMM-PHASE-2-SFH
Sultan khan 2 years ago
parent 680f633d47
commit c3aeec1b6a

@ -106,10 +106,6 @@ echo install diagnostic
ionic cordova plugin add cordova.plugins.diagnostic
npm install @ionic-native/diagnostic
echo install background-geolocation
ionic cordova plugin add cordova-plugin-mauron85-background-geolocation@alpha --variable GOOGLE_PLAY_SERVICES_VERSION="16.0.0"
npm install @ionic-native/background-geolocation
echo install barcode plugin
ionic cordova plugin add phonegap-plugin-barcodescanner
npm install @ionic-native/barcode-scanner

@ -24,7 +24,6 @@
"@ionic-native/android-permissions": "^5.18.0",
"@ionic-native/app-availability": "^5.18.0",
"@ionic-native/app-rate": "^5.18.0",
"@ionic-native/background-geolocation": "^5.30.0",
"@ionic-native/badge": "^5.18.0",
"@ionic-native/barcode-scanner": "^5.18.0",
"@ionic-native/base64": "^5.18.0",
@ -200,9 +199,6 @@
},
"cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-background-geolocation": {
"GOOGLE_PLAY_SERVICES_VERSION": "+"
},
"phonegap-nfc": {},
"wifiwizard2": {},
"cordova-plugin-x-socialsharing": {},

@ -109,7 +109,7 @@ import { NgCalendarModule } from 'ionic2-calendar';
import { DateInfoModalComponent } from './ui/circle-calendar/date-info-modal/date-info-modal.component';
import { ChartModule } from 'primeng/chart';
import { GenericHeaderComponent } from './ui/generic-header/generic-header.component';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
// import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { AttendanceOptionsComponent } from '../home/attendance-options/attendance-options.component';
import { CardCalendarComponent } from './ui/card-calendar/card-calendar.component';
import { WorklistSettingComponent } from '../notification/worklist-setting/worklist-setting.component';
@ -319,7 +319,7 @@ import { SanitizeHtmlPipe } from '../itemforsale/services/domsafe';
MenuService,
OpenNativeSettings,
BarcodeScanner,
BackgroundGeolocation,
// BackgroundGeolocation,
FileOpener,
FilePath,
FileChooser,

@ -1,5 +1,5 @@
import { Injectable } from "@angular/core";
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
// import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { CommonService } from "src/app/hmg-common/services/common/common.service";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service';
@ -13,7 +13,7 @@ declare const cordova: any;
})
export class HMGUtils {
constructor(
public backgroundGeolocation: BackgroundGeolocation,
// public backgroundGeolocation: BackgroundGeolocation,
public common: CommonService,
public ts: TranslatorService,
private geolocation: Geolocation,
@ -25,15 +25,15 @@ export class HMGUtils {
this.devicePermissionsService.requestLocationAutherization().then( async granted => {
if(granted == true) {
if (this.platform.is('android')) {
// if ((await this.isHuaweiDevice())) {
// this.getHMSLocation(callBack);
// } else {
this.getGMSLocation(callBack);
// }
} else {
// if (this.platform.is('android')) {
// // if ((await this.isHuaweiDevice())) {
// // this.getHMSLocation(callBack);
// // } else {
// this.getGMSLocation(callBack);
// // }
// } else {
this.getIOSLocation(callBack);
}
// }
} else {
return false;
}
@ -98,18 +98,18 @@ export class HMGUtils {
}
private getGMSLocation(callBack: Function) {
this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => {
if (resp && (resp.latitude && resp.longitude)) {
const isFakeLocation = resp.isFromMockProvider || resp.mockLocationsEnabled;
const lat = resp.latitude;
const long = resp.longitude;
callBack({"latitude":lat, "longitude":long, "isfake":isFakeLocation})
} else {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
}
}, (error) => {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
});
// this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => {
// if (resp && (resp.latitude && resp.longitude)) {
// const isFakeLocation = resp.isFromMockProvider || resp.mockLocationsEnabled;
// const lat = resp.latitude;
// const long = resp.longitude;
// callBack({"latitude":lat, "longitude":long, "isfake":isFakeLocation})
// } else {
// this.common.presentAlert(this.ts.trPK('home', 'position-error'));
// }
// }, (error) => {
// this.common.presentAlert(this.ts.trPK('home', 'position-error'));
// });
}
private getIOSLocation(callBack: Function) {

@ -14,7 +14,7 @@ import { Response } from 'src/app/hmg-common/services/models/response';
import { Camera, CameraOptions, PictureSourceType} from '@ionic-native/Camera/ngx';
import { DevicePermissionsService } from '../../services/device-permissions/device-permissions.service';
import { Device } from '@ionic-native/device/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
// import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { Platform } from '@ionic/angular';
import { ModalController } from '@ionic/angular';
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
@ -47,7 +47,7 @@ export class AttendScanService {
private permissions: DevicePermissionsService,
public common: CommonService,
public ts: TranslatorService,
public backgroundGeolocation: BackgroundGeolocation,
// public backgroundGeolocation: BackgroundGeolocation,
public platform: Platform,
public modalController: ModalController,
public firebasex: FirebaseX,

@ -17,7 +17,7 @@ import { WifiWizard2 } from "@ionic-native/wifi-wizard-2/ngx";
import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service';
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
// import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
import { HMGUtils } from 'src/app/hmg-common/hmg_utils';
@ -66,7 +66,7 @@ export class AttendanceOptionsComponent implements OnInit {
private openNativeSettings: OpenNativeSettings,
private devicePermissionsService:DevicePermissionsService,
private geolocation: Geolocation,
public backgroundGeolocation: BackgroundGeolocation,
// public backgroundGeolocation: BackgroundGeolocation,
public hmgUtils: HMGUtils
) {}

@ -37,7 +37,7 @@ import { TimeCardService } from '../time-card/service/time-card.service';
import { WorklistMainService } from '../notification/service/work-list.main.service';
import { isThisISOWeek } from 'date-fns';
import { Router } from '@angular/router';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
// import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { NFC, Ndef } from "@ionic-native/nfc/ngx"
import { DigitalIdComponent } from '../authentication/digital-id/digital-id.component';
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
@ -170,7 +170,7 @@ export class HomePage implements OnInit {
public workListService: WorklistMainService,
public router: Router,
private platform: Platform,
public backgroundGeolocation: BackgroundGeolocation,
// public backgroundGeolocation: BackgroundGeolocation,
public modalController: ModalController,
private nfc: NFC,
public firebasex: FirebaseX
@ -282,22 +282,22 @@ export class HomePage implements OnInit {
this.permissions.requestLocationAutherization().then(granted => {
this.location = granted as boolean;
if (this.location) {
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;
}
this.lat = resp.latitude;
this.longt = resp.longitude;
this.attendance();
} else {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
}
}, (error) => {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
});
} else {
// 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;
// }
// this.lat = resp.latitude;
// this.longt = resp.longitude;
// this.attendance();
// } else {
// this.common.presentAlert(this.ts.trPK('home', 'position-error'));
// }
// }, (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;
@ -309,7 +309,7 @@ export class HomePage implements OnInit {
}).catch(error => {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
});
}
// }
} else {
return false;
}

Loading…
Cancel
Save