removed huawei code

NEW-SFH-2022
umasoodch 3 years ago
parent 2d2cba1498
commit 7867befd23

@ -26,11 +26,11 @@ 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);
} }
@ -42,60 +42,60 @@ export class HMGUtils {
} }
async isHuaweiDevice(): Promise<boolean> { // async isHuaweiDevice(): Promise<boolean> {
const result: any = await new Promise((resolve, reject) => { // const result: any = await new Promise((resolve, reject) => {
cordova.plugins.CordovaHMSGMSCheckPlugin.isHmsAvailable( // cordova.plugins.CordovaHMSGMSCheckPlugin.isHmsAvailable(
"index.js", // "index.js",
(_res) => { // (_res) => {
const hmsAvailable = _res === "true"; // const hmsAvailable = _res === "true";
resolve(hmsAvailable); // resolve(hmsAvailable);
}, // },
(_err) => { // (_err) => {
reject({ "status": false, "error": JSON.stringify(_err) }); // reject({ "status": false, "error": JSON.stringify(_err) });
this.common.presentAlert(this.ts.trPK('general', 'huawei-hms-gms-error')); // this.common.presentAlert(this.ts.trPK('general', 'huawei-hms-gms-error'));
} // }
); // );
}); // });
return result; // return result;
} // }
private getHMSLocation(callBack: Function) { // private getHMSLocation(callBack: Function) {
try { // try {
cordova.plugins.CordovaHMSLocationPlugin.requestLocation( // cordova.plugins.CordovaHMSLocationPlugin.requestLocation(
"index.js", // "index.js",
(_res) => { // (_res) => {
console.log("Huawei Location Success: [Stop Getting]"); // console.log("Huawei Location Success: [Stop Getting]");
cordova.plugins.CordovaHMSLocationPlugin.removeLocation("", (_res) => { }, (_err) => { }); // cordova.plugins.CordovaHMSLocationPlugin.removeLocation("", (_res) => { }, (_err) => { });
const location = _res.split(',') // const location = _res.split(',')
console.log(location); // console.log(location);
if (location.length == 3) { // if (location.length == 3) {
let mock = false; // let mock = false;
const lat = Number(_res.split(',')[0]); // const lat = Number(_res.split(',')[0]);
const long = Number(_res.split(',')[1]); // const long = Number(_res.split(',')[1]);
const mockValue = _res.split(',')[2]; // const mockValue = _res.split(',')[2];
// if (mockValue == 'true') { // // if (mockValue == 'true') {
// mock = true; // // mock = true;
// } else { // // } else {
// mock = false; // // mock = false;
// } // // }
callBack({"latitude":lat, "longitude":long, "isfake":mock}) // callBack({"latitude":lat, "longitude":long, "isfake":mock})
} else { // } else {
this.common.presentAlert(this.ts.trPK('general', 'invalid-huawei-location')); // this.common.presentAlert(this.ts.trPK('general', 'invalid-huawei-location'));
} // }
}, // },
(_err) => { // (_err) => {
console.log("Huawei Location [Getting Error]: " + JSON.stringify(_err)); // console.log("Huawei Location [Getting Error]: " + JSON.stringify(_err));
this.common.presentAlert(this.ts.trPK('general', 'invalid-huawei-location')); // this.common.presentAlert(this.ts.trPK('general', 'invalid-huawei-location'));
} // }
); // );
} catch (_err) { // } catch (_err) {
console.log("Huawei Location Plugin [Error]: " + + JSON.stringify(_err)); // console.log("Huawei Location Plugin [Error]: " + + JSON.stringify(_err));
this.common.presentAlert(this.ts.trPK('general', 'huawei-plugin-issue')); // this.common.presentAlert(this.ts.trPK('general', 'huawei-plugin-issue'));
} // }
} // }
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) => {

Loading…
Cancel
Save