Hello I’ve developed an SMS reader application I want to auto submit the message after receiving it is there any way I tried calling that click function using an if based on the length of SMS body but is not working can anyone help me do this
<ion-header>
<ion-toolbar color="primary"></ion-toolbar>
</ion-header>
<ion-content no-padding>
<h2 style="text-align: center;">AUTO SMS READER</h2>
<ion-row>
<ion-col>
<p style="text-align: center;"> Note : Send SMS to this Mobilenumber it will auto read the message</p>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-input type="number" [(ngModel)]="phone" required>{{smsaddress}}</ion-input>
</ion-item>
<ion-item>
<ion-input type="text" [(ngModel)]="message" required>{{smsbody}}</ion-input>
</ion-item>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-button expand="block" (click)="submit()" color="undefined" class="transition">
<strong class="white">
SUBMIT </strong></ion-button>
</ion-col>
</ion-row>
</ion-content>
ts code
ionViewWillEnter() {
this.start();
}
start() {
SMSReceive.startWatch(
() => {
console.log('watch started');
document.addEventListener('onSMSArrive', (e: any) => {
console.log('onSMSArrive()');
var IncomingSMS = e.data;
this.smsaddress = IncomingSMS.address;
this.smsbody = IncomingSMS.body;
console.log(JSON.stringify(this.smsbody))
});
},
() => { console.log('watch start failed') }
)
}
resetdata(){
this.smsaddress="";
this.smsbody="";
}
submit() {
var data = {
phone: this.smsaddress,
message: this.smsbody,
}
const headers = new HttpHeaders();
headers.append('content-type', 'application/json');
this.http.post(this.ip + '/api/test', data,
{ headers: new HttpHeaders({ "content-Type": "application/json" }) }).subscribe(response => {
alert(response);
alert(JSON.stringify(response));
})
this.presentToast('Message has been submitted successfully', false, 'bottom');
this.resetdata();
}