How to send SMS message in ionic 3 using Cordova plugin?(android and IOS)

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: [
    ...
    ...
    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) How to send SMS message in ionic 3 using Cordova plugin?(android and IOS) Reviewed by Sudhan on October 09, 2017 Rating: 5

11 comments:

  1. not working.. error showed like this
    ionic 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

    ReplyDelete
  2. even i was added cordova.js in index.html... Please help me to resolve this

    ReplyDelete
  3. before send adding
    var 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

    ReplyDelete
    Replies
    1. excuse

      intent: 'INTENT' // send SMS with the native android SMS messaging

      not work

      Delete
  4. 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.

    ReplyDelete
  5. Best information about software.Thanks for sharing such great information. hope you keep sharing such kind of information Android Bulk sms sender

    ReplyDelete
  6. Good content and nice blog. Thanks for sharing

    such great information. hope you keep sharing such

    kind of information Android Bulk SMS Sender

    ReplyDelete
  7. 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

    ReplyDelete
  8. Great Information About Bulk SMS !!
    Really Appreciated !!
    One Of The Bestest Blog !
    Have A Look At Our Site Also Bulk SMS Provider !!

    ReplyDelete
  9. 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

    ReplyDelete
  10. thank you for your interesting infomation. sms activation

    ReplyDelete

LightBlog
Powered by Blogger.