2016-07-18 02:09:07 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
|
|
|
|
2016-03-07 02:23:30 +08:00
|
|
|
|
2016-03-13 08:18:08 +08:00
|
|
|
/**
|
|
|
|
* Options for sending an SMS
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
export interface SmsOptions {
|
2016-03-07 02:23:30 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to true to replace \n by a new line. Default: false
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
replaceLineBreaks?: boolean;
|
2016-03-07 02:23:30 +08:00
|
|
|
|
2016-04-30 11:56:49 +08:00
|
|
|
android?: SmsOptionsAndroid;
|
2016-03-07 02:23:30 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-30 11:56:49 +08:00
|
|
|
export interface SmsOptionsAndroid {
|
2016-03-07 02:23:30 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to "INTENT" to send SMS with the native android SMS messaging. Leaving it empty will send the SMS without opening any app.
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
intent?: string;
|
2016-03-07 02:23:30 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-13 07:30:16 +08:00
|
|
|
* @name SMS
|
|
|
|
* @description
|
2016-03-07 02:23:30 +08:00
|
|
|
*
|
|
|
|
* Requires Cordova plugin: cordova-plugin-sms. For more info, please see the [SMS plugin docs](https://github.com/cordova-sms/cordova-sms-plugin).
|
|
|
|
*
|
|
|
|
* @usage
|
2016-07-20 23:17:09 +08:00
|
|
|
* ```typescript
|
|
|
|
* import { SMS } from 'ionic-native';
|
2016-03-25 01:00:18 +08:00
|
|
|
*
|
2016-03-07 02:23:30 +08:00
|
|
|
*
|
2016-03-13 07:30:16 +08:00
|
|
|
* // Send a text message using default options
|
2016-07-20 23:17:09 +08:00
|
|
|
* SMS.send('416123456', 'Hello world!');
|
2016-03-07 02:23:30 +08:00
|
|
|
* ```
|
2016-12-06 22:52:39 +08:00
|
|
|
* @interfaces
|
|
|
|
* SmsOptions
|
|
|
|
* SmsOptionsAndroid
|
2016-03-07 02:23:30 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-28 01:48:50 +08:00
|
|
|
pluginName: 'SMS',
|
2016-03-13 07:33:10 +08:00
|
|
|
plugin: 'cordova-sms-plugin',
|
|
|
|
pluginRef: 'sms',
|
2016-03-15 01:38:35 +08:00
|
|
|
repo: 'https://github.com/cordova-sms/cordova-sms-plugin',
|
|
|
|
platforms: ['Android', 'iOS', 'Windows Phone 8']
|
2016-03-07 02:23:30 +08:00
|
|
|
})
|
|
|
|
export class SMS {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends sms to a number
|
2016-04-30 11:56:49 +08:00
|
|
|
* @param phoneNumber {string|Array<string>} Phone number
|
2016-03-13 08:18:08 +08:00
|
|
|
* @param message {string} Message
|
2016-04-30 11:56:49 +08:00
|
|
|
* @param options {SmsOptions} Options
|
2016-03-13 08:18:08 +08:00
|
|
|
* @returns {Promise<any>} Resolves promise when the SMS has been sent
|
2016-03-07 02:23:30 +08:00
|
|
|
*/
|
2016-12-11 09:05:24 +08:00
|
|
|
@Cordova({
|
|
|
|
successIndex: 3,
|
|
|
|
errorIndex: 4
|
|
|
|
})
|
2016-03-11 05:48:20 +08:00
|
|
|
static send(
|
2016-04-30 11:56:49 +08:00
|
|
|
phoneNumber: string | string[],
|
2016-03-11 05:48:20 +08:00
|
|
|
message: string,
|
2016-04-30 11:56:49 +08:00
|
|
|
options?: SmsOptions
|
2016-10-27 20:14:47 +08:00
|
|
|
): Promise<any> { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function lets you know if the app has permission to send SMS
|
|
|
|
* @return {Promise<boolean>} returns a promise that resolves with a boolean that indicates if we have permission
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
platforms: ['Android']
|
|
|
|
})
|
|
|
|
static hasPermission(): Promise<boolean> { return; }
|
2016-03-07 02:23:30 +08:00
|
|
|
|
|
|
|
}
|