SMS
Requires Cordova plugin: cordova-sms-plugin. For more info, please see the SMS plugin docs.
Repo: https://github.com/cordova-sms/cordova-sms-plugin
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-sms-plugin $ npm install --save @ionic-native/sms@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
- Windows
- Windows Phone 8
Usage
import { SMS } from '@ionic-native/sms';
constructor(private sms: SMS) { }
...
// Send a text message using default options
this.sms.send('416123456', 'Hello world!');
Instance Members
send(phoneNumber, message, options)
Sends sms to a number
Param | Type | Details |
---|---|---|
phoneNumber |
string |Array.<string>
|
Phone number |
message |
string
|
Message |
options |
SmsOptions
|
Options |
Returns: Promise<any>
Resolves promise when the SMS has been sent
hasPermission()
Platforms:Android
This function lets you know if the app has permission to send SMS
Returns: Promise<boolean>
returns a promise that resolves with a boolean that indicates if we have permission
SmsOptions
Param | Type | Details |
---|---|---|
replaceLineBreaks |
boolean
|
Set to true to replace \n by a new line. Default: false (optional) |
android |
SmsOptionsAndroid
|
(optional) |
SmsOptionsAndroid
Param | Type | Details |
---|---|---|
intent |
string
|
Set to "INTENT" to send SMS with the native android SMS messaging. Leaving it empty will send the SMS without opening any app. (optional) |