added check code for huawei device

MOHEMM-HUAWEI-RELEASE
umasoodch 4 years ago
parent 438a8dce03
commit 5411a068bf

@ -27,6 +27,7 @@ import org.json.JSONException;
/**
*
*/
// https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-References-V1/data-types-0000001056511617-V1#section2512153819346
public class CordovaHMSLocationPlugin extends CordovaPlugin {
private static final String TAG = CordovaHMSLocationPlugin.class.getSimpleName();
@ -62,7 +63,7 @@ public class CordovaHMSLocationPlugin extends CordovaPlugin {
private void returnLocation(Location location) {
if (mCallbackContext != null) {
Log.d(TAG, "returnLocation");
String message = location.getLatitude() + "," + location.getLongitude();
String message = location.getLatitude() + "," + location.getLongitude() + "," + location.isFromMockProvider();
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
result.setKeepCallback(true);
mCallbackContext.sendPluginResult(result);

@ -106,7 +106,7 @@
<splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
</platform>
<platform name="android">
<preference name="android-minSdkVersion" value="21" />
<preference name="android-minSdkVersion" value="22" />
<preference name="android-targetSdkVersion" value="30" />
</platform>
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />

@ -136,6 +136,8 @@
"@types/jasminewd2": "~2.0.3",
"@types/node": "~10.12.0",
"codelyzer": "~4.5.0",
"com.huawei.cordovahmsgmscheckplugin": "file:CordovaHMSPlugin/CordovaHMSGMSCheckPlugin",
"com.huawei.cordovahmslocationplugin": "file:CordovaHMSPlugin/CordovaHMSLocationPlugin",
"cordova-ios": "^6.2.0",
"cordova-plugin-wifiwizard2": "^3.1.1",
"es6-promise-plugin": "^4.1.0",
@ -201,6 +203,8 @@
},
"phonegap-nfc": {},
"wifiwizard2": {},
"com.huawei.cordovahmsgmscheckplugin": {},
"com.huawei.cordovahmslocationplugin": {},
"cordova-plugin-x-socialsharing": {},
"cordova-plugin-firebasex": {
"FIREBASE_ANALYTICS_COLLECTION_ENABLED": "true",

@ -41,7 +41,7 @@ export class HMGUtils {
async isHuaweiDevice(): Promise<boolean> {
var result = await new Promise((resolve, reject) => {
var result: any = await new Promise((resolve, reject) => {
cordova.plugins.CordovaHMSGMSCheckPlugin.isHmsAvailable(
"index.js",
(_res) => {
@ -50,12 +50,12 @@ export class HMGUtils {
},
(_err) => {
reject({ "status": false, "error": JSON.stringify(_err) });
alert("Error checking device HMS/GMS")
alert("Error checking device HMS/GMS") // add your popup
}
);
});
return (result == true);
return result;
}
private getHMSLocation(callBack: Function) {
@ -68,10 +68,12 @@ export class HMGUtils {
console.log("Huawei Location Success: [Stop Getting]");
cordova.plugins.CordovaHMSLocationPlugin.removeLocation("", (_res) => { }, (_err) => { });
var location = _res.split(',')
console.log(location);
if (location.length == 2) {
var lat = Number(_res.split(',')[0]);
var long = Number(_res.split(',')[1]);
callBack({"latitude":lat, "longitude":long, "isfake":false})
var mock = Boolean(_res.split(',')[2]);
callBack({"latitude":lat, "longitude":long, "isfake":mock})
} else {
alert("Invalid Huawei location from plugin.");
}

@ -19,6 +19,7 @@
</ion-col>
</ion-row>
<p>umarrrrrrrrrrrrrrrr {{check}}</p>
<ion-row padding>
<ion-col size="5" [ngClass]="{'margin-col': direction === 'en', 'disable-attendance': !serviceEnableNFC}" class="buttonStyle" >
<div class="textAndIcon" (click)="startNFCCode()">

@ -19,7 +19,9 @@ import { DevicePermissionsService } from 'src/app/hmg-common/services/device-per
import { Geolocation } from '@ionic-native/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';
declare var cordova: any;
@Component({
selector: "app-attendance-options",
@ -47,6 +49,7 @@ export class AttendanceOptionsComponent implements OnInit {
public firebasex: FirebaseX
public isDocumentAvailable = false;
public document: any;
public check: any;
constructor(
@ -63,7 +66,8 @@ export class AttendanceOptionsComponent implements OnInit {
private openNativeSettings: OpenNativeSettings,
private devicePermissionsService:DevicePermissionsService,
private geolocation: Geolocation,
public backgroundGeolocation: BackgroundGeolocation
public backgroundGeolocation: BackgroundGeolocation,
public hmgUtils: HMGUtils
) {}
ngOnInit() {
@ -76,6 +80,18 @@ export class AttendanceOptionsComponent implements OnInit {
this.priviligeList = AuthenticationService.servicePrivilage;
this.setServicesPrivilage();
this.checkNFCStatus("one");
this.test();
}
async test () {
const test = await this.hmgUtils.isHuaweiDevice();
if (test) {
this.check = 'this device is huawei device :' + test;
console.log('this device is huawei device :' + test);
} else {
this.check = 'this device is not huawei device :' + test;
console.log('this device is non-huawei device :' + test);
}
}
public checkFirebaseDocument() {

Loading…
Cancel
Save