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 { ConfirmLoginComponent } from '../authentication/confirm-login/confirm-login.component'
import { WelcomeComponent } from '../authentication/welcome/welcome.component'
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
const routes: Routes = [
{
@ -87,7 +88,8 @@ const routes: Routes = [
providers: [
FingerprintAIO,
Device,
SplashScreen
SplashScreen,
SmsRetriever
],
entryComponents: []
})

@ -22,6 +22,7 @@ import { DigitalIdComponent } from '../digital-id/digital-id.component';
import { AppUpdateComponent } from '../app-update/app-update.component';
import { Password } from '../models/password';
import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request';
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
@Component({
selector: 'app-confirm-login',
@ -57,6 +58,7 @@ export class ConfirmLoginComponent implements OnInit {
userInfo: any;
public businessInfo: object;
private checkUserResult: CheckUserAuthenticationResponse;
private signature: string;
constructor(
public ts: TranslatorService,
public cs: CommonService,
@ -67,7 +69,8 @@ export class ConfirmLoginComponent implements OnInit {
public platform: Platform,
public modalController: ModalController,
public alertController: AlertController,
private nfc: NFC
private nfc: NFC,
private smsRetriever: SmsRetriever
) {
this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, 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.userInfo = JSON.parse(localStorage.getItem('digitalIDUser'));
this.checkNFCStatus();
this.generateSMSsignature();
// **checkIfAvailable FAIO **//
this.checkIfAvailable();
// **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) {
console.log(this.signature);
const request = new SendActivationByType();
this.authService.setPublicFields(request);
request.OTP_SendType = type;
request.MobileNumber = this.loginData.MobileNumber;
request.MobileNumber = '0593233758';//this.loginData.MobileNumber;
request.smsSignature = this.signature;
request.IsMobileFingerPrint = 0;
request.P_USER_NAME = this.loginData.P_USER_NAME;

@ -9,6 +9,7 @@ export class SendActivationByType extends Request {
OTP_SendType: number;
IsMobileFingerPrint: number;
P_LEGISLATION_CODE: string;
smsSignature: 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 * as moment from 'moment';
import { NFC } from "@ionic-native/nfc/ngx";
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
@Component({
selector: 'app-sms-page',
templateUrl: './sms-page.page.html',
@ -53,7 +53,7 @@ export class SmsPageComponent implements OnInit {
public showErrorMessage = false;
public messageValue: string;
public businessInfo: object;
public isAutoRead: boolean = false;
constructor(
public navCtrl: NavController,
public translate: TranslatorService,
@ -62,7 +62,8 @@ export class SmsPageComponent implements OnInit {
public authService: AuthenticationService,
public sharedData: SharedDataService,
public platform: Platform,
private nfc: NFC
private nfc: NFC,
private smsRetriever: SmsRetriever
) { }
ngOnInit() {
@ -91,9 +92,18 @@ export class SmsPageComponent implements OnInit {
} else {
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() {
if (!this.timeInSeconds) {
this.timeInSeconds = 120;
@ -290,7 +300,7 @@ export class SmsPageComponent implements OnInit {
return el;
}
});
if (filtered.length === 4) {
if (filtered.length === 4 && !this.isAutoRead) {
this.checkVerificationCode();
}
}

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

Loading…
Cancel
Save