capacitor-sms-sender-fork
v1.0.2
Published
Send SMS directly from capacitor app
Downloads
9
Maintainers
Readme
capacitor-sms-sender
Send SMS directly from capacitor app - fork of iqomp/capacitor-sms-sender - now compatible with capacitor 5+
Install
npm install capacitor-sms-sender-fork
npx cap sync
Example
import { SmsSender } from 'capacitor-sms-sender-fork'
let opts = {
id: 1,
sim: 0,
phone: '+123020021',
text: 'Hi There'
}
SmsSender.send(opts)
.then(res => {
console.log(res)
})
SmsSender.addListener('smsSenderDelivered', res => {
console.log(res)
})
API
send(...)
checkPermissions()
requestPermissions()
addListener('smsSenderDelivered', ...)
removeAllListeners()
- Interfaces
- Type Aliases
send(...)
send(opts: SmsSenderOptions) => Promise<SmsSenderResult>
Send a text sms to a number from a specified sim index
| Param | Type |
| ---------- | ------------------------------------------------------------- |
| opts
| SmsSenderOptions |
Returns: Promise<SmsSenderResult>
Since: 1.0.0
checkPermissions()
checkPermissions() => Promise<PermissionStatus>
Check status of permissions
Returns: Promise<PermissionStatus>
Since: 1.0.0
requestPermissions()
requestPermissions() => Promise<PermissionStatus>
Request the required permissions
Returns: Promise<PermissionStatus>
addListener('smsSenderDelivered', ...)
addListener(eventName: 'smsSenderDelivered', listenerFunc: (result: SmsSenderResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for sms status update
| Param | Type |
| ------------------ | -------------------------------------------------------------------------------- |
| eventName
| 'smsSenderDelivered' |
| listenerFunc
| (result: SmsSenderResult) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 1.0.0
removeAllListeners()
removeAllListeners() => Promise<void>
Remove all registered listeners
Since: 1.0.0
Interfaces
SmsSenderResult
| Prop | Type | Description | Since |
| ------------ | ------------------- | -------------------------------------------------------------------- | ----- |
| id
| number | Message SMS id | 1.0.0 |
| status
| string | Delivery status, possible value are 'FAILED', 'SENT', or 'DELIVERED' | 1.0.0 |
SmsSenderOptions
| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------- | ----- |
| id
| number | SMS Message id | 1.0.0 |
| sim
| number | Device SIM index | 1.0.0 |
| phone
| string | Target phone number | 1.0.0 |
| text
| string | SMS Message | 1.0.0 |
PermissionStatus
| Prop | Type | Description | Since |
| ---------------------- | ----------------------------------------------------------- | --------------------------- | ----- |
| send_sms
| PermissionState | SEND_SMS Permission | 1.0.0 |
| read_phone_state
| PermissionState | READ_PHONE_STATE Permission | 1.0.0 |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Type Aliases
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'