auto sms read feature

sultan-q3
Sultan Khan 4 years ago
parent 985103bdb5
commit e765d81711

@ -22,6 +22,7 @@ import { CheckUserComponent } from './check-user/check-user.component';
import { ChangePasswordComponent } from './change-password/change-password.component'; import { ChangePasswordComponent } from './change-password/change-password.component';
import { ConfirmLoginComponent } from '../authentication/confirm-login/confirm-login.component' import { ConfirmLoginComponent } from '../authentication/confirm-login/confirm-login.component'
import { WelcomeComponent } from '../authentication/welcome/welcome.component' import { WelcomeComponent } from '../authentication/welcome/welcome.component'
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
const routes: Routes = [ const routes: Routes = [
{ {
@ -87,7 +88,8 @@ const routes: Routes = [
providers: [ providers: [
FingerprintAIO, FingerprintAIO,
Device, Device,
SplashScreen SplashScreen,
SmsRetriever
], ],
entryComponents: [] entryComponents: []
}) })

@ -22,6 +22,7 @@ import { DigitalIdComponent } from '../digital-id/digital-id.component';
import { AppUpdateComponent } from '../app-update/app-update.component'; import { AppUpdateComponent } from '../app-update/app-update.component';
import { Password } from '../models/password'; import { Password } from '../models/password';
import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request'; import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request';
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
@Component({ @Component({
selector: 'app-confirm-login', selector: 'app-confirm-login',
@ -57,6 +58,7 @@ export class ConfirmLoginComponent implements OnInit {
userInfo: any; userInfo: any;
public businessInfo: object; public businessInfo: object;
private checkUserResult: CheckUserAuthenticationResponse; private checkUserResult: CheckUserAuthenticationResponse;
private signature: string;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
public cs: CommonService, public cs: CommonService,
@ -67,7 +69,8 @@ export class ConfirmLoginComponent implements OnInit {
public platform: Platform, public platform: Platform,
public modalController: ModalController, public modalController: ModalController,
public alertController: AlertController, public alertController: AlertController,
private nfc: NFC private nfc: NFC,
private smsRetriever: SmsRetriever
) { ) {
this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
@ -87,6 +90,7 @@ export class ConfirmLoginComponent implements OnInit {
this.direction = TranslatorService.getCurrentLanguageName(); this.direction = TranslatorService.getCurrentLanguageName();
this.userInfo = JSON.parse(localStorage.getItem('digitalIDUser')); this.userInfo = JSON.parse(localStorage.getItem('digitalIDUser'));
this.checkNFCStatus(); this.checkNFCStatus();
this.generateSMSsignature();
// **checkIfAvailable FAIO **// // **checkIfAvailable FAIO **//
this.checkIfAvailable(); this.checkIfAvailable();
// **getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **// // **getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **//
@ -228,13 +232,18 @@ export class ConfirmLoginComponent implements OnInit {
} }
public generateSMSsignature() {
this.smsRetriever.getAppHash()
.then((res: any) => this.signature = res)
.catch((error: any) => console.error(error));
}
public sendActivationCode(type: number) { public sendActivationCode(type: number) {
console.log(this.signature);
const request = new SendActivationByType(); const request = new SendActivationByType();
this.authService.setPublicFields(request); this.authService.setPublicFields(request);
request.OTP_SendType = type; request.OTP_SendType = type;
request.MobileNumber = this.loginData.MobileNumber; request.MobileNumber = '0593233758';//this.loginData.MobileNumber;
request.smsSignature = this.signature;
request.IsMobileFingerPrint = 0; request.IsMobileFingerPrint = 0;
request.P_USER_NAME = this.loginData.P_USER_NAME; request.P_USER_NAME = this.loginData.P_USER_NAME;

@ -9,6 +9,7 @@ export class SendActivationByType extends Request {
OTP_SendType: number; OTP_SendType: number;
IsMobileFingerPrint: number; IsMobileFingerPrint: number;
P_LEGISLATION_CODE: string; P_LEGISLATION_CODE: string;
smsSignature: string;
// VersionID:string; // VersionID:string;

@ -13,7 +13,7 @@ import { Password } from '../models/password';
import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request'; import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request';
import * as moment from 'moment'; import * as moment from 'moment';
import { NFC } from "@ionic-native/nfc/ngx"; import { NFC } from "@ionic-native/nfc/ngx";
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
@Component({ @Component({
selector: 'app-sms-page', selector: 'app-sms-page',
templateUrl: './sms-page.page.html', templateUrl: './sms-page.page.html',
@ -53,7 +53,7 @@ export class SmsPageComponent implements OnInit {
public showErrorMessage = false; public showErrorMessage = false;
public messageValue: string; public messageValue: string;
public businessInfo: object; public businessInfo: object;
public isAutoRead: boolean = false;
constructor( constructor(
public navCtrl: NavController, public navCtrl: NavController,
public translate: TranslatorService, public translate: TranslatorService,
@ -62,7 +62,8 @@ export class SmsPageComponent implements OnInit {
public authService: AuthenticationService, public authService: AuthenticationService,
public sharedData: SharedDataService, public sharedData: SharedDataService,
public platform: Platform, public platform: Platform,
private nfc: NFC private nfc: NFC,
private smsRetriever: SmsRetriever
) { } ) { }
ngOnInit() { ngOnInit() {
@ -91,9 +92,18 @@ export class SmsPageComponent implements OnInit {
} else { } else {
this.loginType = 1; this.loginType = 1;
} }
this.smsRetriever.startWatching()
.then((res: any) => this.checkActivation(res))
.catch((error: any) => console.error(error));
}
checkActivation(res) {
this.isAutoRead = true;
var pattern = /\d+/g;
var code = res.Message.match(pattern)[0];
this.activationCode = code
this.smc_code = code.split('');
this.checkVerificationCode();
} }
initTimer() { initTimer() {
if (!this.timeInSeconds) { if (!this.timeInSeconds) {
this.timeInSeconds = 120; this.timeInSeconds = 120;
@ -290,7 +300,7 @@ export class SmsPageComponent implements OnInit {
return el; return el;
} }
}); });
if (filtered.length === 4) { if (filtered.length === 4 && !this.isAutoRead) {
this.checkVerificationCode(); this.checkVerificationCode();
} }
} }

@ -27,8 +27,8 @@ export class ConnectorService {
public static retryTimes = 0; public static retryTimes = 0;
public static timeOut = 120 * 1000; public static timeOut = 120 * 1000;
// public static host = 'https://uat.hmgwebservices.com/'; public static host = 'https://uat.hmgwebservices.com/';
public static host = 'https://hmgwebservices.com/'; //public static host = 'https://hmgwebservices.com/';
constructor(public httpClient: HttpClient, constructor(public httpClient: HttpClient,
public cs: CommonService, public cs: CommonService,

Loading…
Cancel
Save