Ionic 3 get firebase phone list in loop and and insert phone number in sms api to send message to all my number in firebase


#1

Preformatted texthis is my code i wnat to send msg to all my number which is in firebase list how can i do it i try to get list from fire base insert number in sms gate api i am able to send msg by write number and sms but i want to send sms automatically to all phone number in fire data base.please help me out ,and sorry i weak in english
export class MessagePage {
num;
msg;
phonenumber;
contactList: FirebaseListObservable<any[]>;contact={
phone:’’
}
constructor(public navCtrl: NavController,public firebaseProvider: FirebaseProvider,public http: Http) {
this.contactList=this.firebaseProvider.getContactList();

}
postRequest() {
var headers = new Headers();
headers.append(“Accept”, ‘application/json’);
headers.append(‘Content-Type’, ‘application/json’ );
let options = new RequestOptions({ headers: headers });

let postParams = {
title: ‘foo’,
body: ‘bar’,
userId: 1
}
this.http.post(“http://www.sms4connect.com/api/sendsms.php/sendsms/url?id=xxxxxxxxx&pass=xxxxxxxx&msg="+this.msg+"&to="+this.num+"&mask=COMP SMS&type=xml&lang=English”, postParams, options)
.subscribe(data => {
console.log(data[’_body’]);
}, error => {
console.log(error);// Error getting the data
});
}

}

ion-header>





Message



<ion-content padding id=“page2” #content>
<ion-input [(ngModel)]=“num” placeholder="Write your number " >
<ion-input [(ngModel)]=“msg” placeholder=“Write your message …”>
<button (click)=postRequest() id=“message-button1” ion-button color=“positive” block>
Send Message

<ion-item-sliding *ngFor=“let contact of contactList | async”>

{{contact.phone}}



#2

I think you should use Firestore and AngularFire2.


#3

yes i m using firebase angular 2


#4

i need a slution to send msg from my sms gateway api to all firebase contact list