Hi, I am going teach about how to send SMS message in ionic 3 and Angular 4.
First, we want to install the Cordova and ionic Native Plugin.
$ ionic cordova plugin add cordova-sms-plugin
$ npm install --save @ionic-native/sms
Home.html
<ion-header>
<ion-navbar>
<ion-title>
SMS
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding fullscreen="true">
<div style="margin-top: 3cm">
<ion-list>
<ion-item>
<ion-label floating>Message</ion-label>
<ion-input type="text" name="message" [(ngModel)]="message"></ion-input>
</ion-item>
</ion-list>
<div text-center>
<button ion-button (tap)="send()">Send</button>
</div>
</div>
</ion-content>
app.module.ts
import { SMS } from '@ionic-native/sms';
providers: [
...
...
First, we want to install the Cordova and ionic Native Plugin.
$ ionic cordova plugin add cordova-sms-plugin
$ npm install --save @ionic-native/sms
Home.html
<ion-header>
<ion-navbar>
<ion-title>
SMS
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding fullscreen="true">
<div style="margin-top: 3cm">
<ion-list>
<ion-item>
<ion-label floating>Message</ion-label>
<ion-input type="text" name="message" [(ngModel)]="message"></ion-input>
</ion-item>
</ion-list>
<div text-center>
<button ion-button (tap)="send()">Send</button>
</div>
</div>
</ion-content>
app.module.ts
import { SMS } from '@ionic-native/sms';
providers: [
...
...
SMS,
...
]
Html.ts
import { Component } from '@angular/core'; import {NavController, ToastController} from 'ionic-angular'; import { SMS } from '@ionic-native/sms'; @Component({ selector: 'page-home', templateUrl: 'home.html'}) export class HomePage { message:any; constructor(private sms: SMS,public toastCtrl: ToastController) { this.message = ''; } send(){ this.sms.send("9XXXXXXXX3", this.message) .then(()=>{ let toast = this.toastCtrl.create({ message: 'Message send successfully', duration: 3000 }); toast.present(); },()=>{ let toast = this.toastCtrl.create({ message: 'Failure', duration: 3000 }); toast.present(); }); } }
How to send SMS message in ionic 3 using Cordova plugin?(android and IOS)
Reviewed by Sudhan
on
October 09, 2017
Rating:
not working.. error showed like this
ReplyDeleteionic Native: tried calling SMS.send, but Cordova is not available. Make sure to a) run in a real device or simulator and b) include cordova.js in your index.html
even i was added cordova.js in index.html... Please help me to resolve this
ReplyDeletebefore send adding
ReplyDeletevar options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without opening any other app
}
};
and
this.sms.send("04125802176", this.message,options)
with intent="" does not work for me either
excuse
Deleteintent: 'INTENT' // send SMS with the native android SMS messaging
not work
sms gateway appSMS Gateway Provider - If you are confused for how to send bulk SMS? Then download the best SMS gateway apps for Android from SMS-Api-Gateway. It helps you to send bulk SMS.
ReplyDeleteBest information about software.Thanks for sharing such great information. hope you keep sharing such kind of information Android Bulk sms sender
ReplyDeleteGood content and nice blog. Thanks for sharing
ReplyDeletesuch great information. hope you keep sharing such
kind of information Android Bulk SMS Sender
Now a day sms marketing is the best way to increase sale of you product.Thanks for sharing such great information. hope you keep sharing such kind of information sms sender software
ReplyDeleteGreat Information About Bulk SMS !!
ReplyDeleteReally Appreciated !!
One Of The Bestest Blog !
Have A Look At Our Site Also Bulk SMS Provider !!
Nice Article, SMS marketing does not necessitate tremendous planning or plotting. You need not draft a design, mock-up content or scale outlines for the ad.Message Sender App is a multiple SMS sending tool from Multiple Android phones through a single platform at once bulk sms sender
ReplyDeletethank you for your interesting infomation. sms activation
ReplyDelete