awesome-cordova-plugins/src/plugins/sms.ts

81 lines
1.8 KiB
TypeScript
Raw Normal View History

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
*/
export interface SmsOptions {
2016-03-07 02:23:30 +08:00
/**
* Set to true to replace \n by a new line. Default: false
*/
replaceLineBreaks?: boolean;
2016-03-07 02:23:30 +08:00
android?: SmsOptionsAndroid;
2016-03-07 02:23:30 +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.
*/
intent?: string;
2016-03-07 02:23:30 +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
* ```typescript
* import { SMS } from 'ionic-native';
*
2016-03-07 02:23:30 +08:00
*
* // Send a text message using default options
* 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({
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
* @param phoneNumber {string|Array<string>} Phone number
2016-03-13 08:18:08 +08:00
* @param message {string} Message
* @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
*/
@Cordova({
successIndex: 3,
errorIndex: 4
})
static send(
phoneNumber: string | string[],
message: string,
options?: SmsOptions
): 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
}