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 ionic cordova plugin add cordova.plugins.diagnostic
npm install @ionic-native/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 echo install barcode plugin
ionic cordova plugin add phonegap-plugin-barcodescanner ionic cordova plugin add phonegap-plugin-barcodescanner
npm install @ionic-native/barcode-scanner npm install @ionic-native/barcode-scanner

@ -24,7 +24,6 @@
"@ionic-native/android-permissions": "^5.18.0", "@ionic-native/android-permissions": "^5.18.0",
"@ionic-native/app-availability": "^5.18.0", "@ionic-native/app-availability": "^5.18.0",
"@ionic-native/app-rate": "^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/badge": "^5.18.0",
"@ionic-native/barcode-scanner": "^5.18.0", "@ionic-native/barcode-scanner": "^5.18.0",
"@ionic-native/base64": "^5.18.0", "@ionic-native/base64": "^5.18.0",
@ -200,9 +199,6 @@
}, },
"cordova-plugin-androidx": {}, "cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {}, "cordova-plugin-androidx-adapter": {},
"cordova-plugin-background-geolocation": {
"GOOGLE_PLAY_SERVICES_VERSION": "+"
},
"phonegap-nfc": {}, "phonegap-nfc": {},
"wifiwizard2": {}, "wifiwizard2": {},
"cordova-plugin-x-socialsharing": {}, "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 { DateInfoModalComponent } from './ui/circle-calendar/date-info-modal/date-info-modal.component';
import { ChartModule } from 'primeng/chart'; import { ChartModule } from 'primeng/chart';
import { GenericHeaderComponent } from './ui/generic-header/generic-header.component'; 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 { AttendanceOptionsComponent } from '../home/attendance-options/attendance-options.component';
import { CardCalendarComponent } from './ui/card-calendar/card-calendar.component'; import { CardCalendarComponent } from './ui/card-calendar/card-calendar.component';
import { WorklistSettingComponent } from '../notification/worklist-setting/worklist-setting.component'; import { WorklistSettingComponent } from '../notification/worklist-setting/worklist-setting.component';
@ -319,7 +319,7 @@ import { SanitizeHtmlPipe } from '../itemforsale/services/domsafe';
MenuService, MenuService,
OpenNativeSettings, OpenNativeSettings,
BarcodeScanner, BarcodeScanner,
BackgroundGeolocation, // BackgroundGeolocation,
FileOpener, FileOpener,
FilePath, FilePath,
FileChooser, FileChooser,

@ -1,5 +1,5 @@
import { Injectable } from "@angular/core"; 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 { CommonService } from "src/app/hmg-common/services/common/common.service";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.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'; import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service';
@ -13,7 +13,7 @@ declare const cordova: any;
}) })
export class HMGUtils { export class HMGUtils {
constructor( constructor(
public backgroundGeolocation: BackgroundGeolocation, // public backgroundGeolocation: BackgroundGeolocation,
public common: CommonService, public common: CommonService,
public ts: TranslatorService, public ts: TranslatorService,
private geolocation: Geolocation, private geolocation: Geolocation,
@ -25,15 +25,15 @@ export class HMGUtils {
this.devicePermissionsService.requestLocationAutherization().then( async granted => { this.devicePermissionsService.requestLocationAutherization().then( async granted => {
if(granted == true) { if(granted == true) {
if (this.platform.is('android')) { // if (this.platform.is('android')) {
// if ((await this.isHuaweiDevice())) { // // if ((await this.isHuaweiDevice())) {
// this.getHMSLocation(callBack); // // this.getHMSLocation(callBack);
// } else { // // } else {
this.getGMSLocation(callBack); // this.getGMSLocation(callBack);
// } // // }
} else { // } else {
this.getIOSLocation(callBack); this.getIOSLocation(callBack);
} // }
} else { } else {
return false; return false;
} }
@ -98,18 +98,18 @@ export class HMGUtils {
} }
private getGMSLocation(callBack: Function) { private getGMSLocation(callBack: Function) {
this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { // this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => {
if (resp && (resp.latitude && resp.longitude)) { // if (resp && (resp.latitude && resp.longitude)) {
const isFakeLocation = resp.isFromMockProvider || resp.mockLocationsEnabled; // const isFakeLocation = resp.isFromMockProvider || resp.mockLocationsEnabled;
const lat = resp.latitude; // const lat = resp.latitude;
const long = resp.longitude; // const long = resp.longitude;
callBack({"latitude":lat, "longitude":long, "isfake":isFakeLocation}) // callBack({"latitude":lat, "longitude":long, "isfake":isFakeLocation})
} else { // } else {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); // this.common.presentAlert(this.ts.trPK('home', 'position-error'));
} // }
}, (error) => { // }, (error) => {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); // this.common.presentAlert(this.ts.trPK('home', 'position-error'));
}); // });
} }
private getIOSLocation(callBack: Function) { 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 { Camera, CameraOptions, PictureSourceType} from '@ionic-native/Camera/ngx';
import { DevicePermissionsService } from '../../services/device-permissions/device-permissions.service'; import { DevicePermissionsService } from '../../services/device-permissions/device-permissions.service';
import { Device } from '@ionic-native/device/ngx'; 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 { Platform } from '@ionic/angular';
import { ModalController } from '@ionic/angular'; import { ModalController } from '@ionic/angular';
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; import { FirebaseX } from '@ionic-native/firebase-x/ngx';
@ -47,7 +47,7 @@ export class AttendScanService {
private permissions: DevicePermissionsService, private permissions: DevicePermissionsService,
public common: CommonService, public common: CommonService,
public ts: TranslatorService, public ts: TranslatorService,
public backgroundGeolocation: BackgroundGeolocation, // public backgroundGeolocation: BackgroundGeolocation,
public platform: Platform, public platform: Platform,
public modalController: ModalController, public modalController: ModalController,
public firebasex: FirebaseX, 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 { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service'; import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service';
import { Geolocation } from '@ionic-native/geolocation/ngx'; 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 { FirebaseX } from '@ionic-native/firebase-x/ngx';
import { HMGUtils } from 'src/app/hmg-common/hmg_utils'; import { HMGUtils } from 'src/app/hmg-common/hmg_utils';
@ -66,7 +66,7 @@ export class AttendanceOptionsComponent implements OnInit {
private openNativeSettings: OpenNativeSettings, private openNativeSettings: OpenNativeSettings,
private devicePermissionsService:DevicePermissionsService, private devicePermissionsService:DevicePermissionsService,
private geolocation: Geolocation, private geolocation: Geolocation,
public backgroundGeolocation: BackgroundGeolocation, // public backgroundGeolocation: BackgroundGeolocation,
public hmgUtils: HMGUtils 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 { WorklistMainService } from '../notification/service/work-list.main.service';
import { isThisISOWeek } from 'date-fns'; import { isThisISOWeek } from 'date-fns';
import { Router } from '@angular/router'; 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 { NFC, Ndef } from "@ionic-native/nfc/ngx"
import { DigitalIdComponent } from '../authentication/digital-id/digital-id.component'; import { DigitalIdComponent } from '../authentication/digital-id/digital-id.component';
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; import { FirebaseX } from '@ionic-native/firebase-x/ngx';
@ -170,7 +170,7 @@ export class HomePage implements OnInit {
public workListService: WorklistMainService, public workListService: WorklistMainService,
public router: Router, public router: Router,
private platform: Platform, private platform: Platform,
public backgroundGeolocation: BackgroundGeolocation, // public backgroundGeolocation: BackgroundGeolocation,
public modalController: ModalController, public modalController: ModalController,
private nfc: NFC, private nfc: NFC,
public firebasex: FirebaseX public firebasex: FirebaseX
@ -282,22 +282,22 @@ export class HomePage implements OnInit {
this.permissions.requestLocationAutherization().then(granted => { this.permissions.requestLocationAutherization().then(granted => {
this.location = granted as boolean; this.location = granted as boolean;
if (this.location) { if (this.location) {
if (this.platform.is('android')) { // if (this.platform.is('android')) {
this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { // this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => {
if (resp && (resp.latitude && resp.longitude)) { // if (resp && (resp.latitude && resp.longitude)) {
if (resp.isFromMockProvider || resp.mockLocationsEnabled) { // if (resp.isFromMockProvider || resp.mockLocationsEnabled) {
this.isFakeLocationUsed = true; // this.isFakeLocationUsed = true;
} // }
this.lat = resp.latitude; // this.lat = resp.latitude;
this.longt = resp.longitude; // this.longt = resp.longitude;
this.attendance(); // this.attendance();
} else { // } else {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); // this.common.presentAlert(this.ts.trPK('home', 'position-error'));
} // }
}, (error) => { // }, (error) => {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); // this.common.presentAlert(this.ts.trPK('home', 'position-error'));
}); // });
} else { // } else {
this.geolocation.getCurrentPosition({ maximumAge: 3000, timeout: 10000, enableHighAccuracy: true }).then(resp => { this.geolocation.getCurrentPosition({ maximumAge: 3000, timeout: 10000, enableHighAccuracy: true }).then(resp => {
if (resp && resp.coords.latitude && resp.coords.longitude) { if (resp && resp.coords.latitude && resp.coords.longitude) {
this.lat = resp.coords.latitude; this.lat = resp.coords.latitude;
@ -309,7 +309,7 @@ export class HomePage implements OnInit {
}).catch(error => { }).catch(error => {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); this.common.presentAlert(this.ts.trPK('home', 'position-error'));
}); });
} // }
} else { } else {
return false; return false;
} }

Loading…
Cancel
Save