Send SMS directly from capacitor app
npm install capacitor-sms-sender
npx cap sync
import { SmsSender } from 'capacitor-sms-sender'
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)
})
send(...)
checkPermissions()
requestPermissions()
addListener('smsSenderDelivered', ...)
removeAllListeners()
- Interfaces
- Type Aliases
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() => Promise<PermissionStatus>
Check status of permissions
Returns: Promise<PermissionStatus>
Since: 1.0.0
requestPermissions() => Promise<PermissionStatus>
Request the required permissions
Returns: Promise<PermissionStatus>
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() => Promise<void>
Remove all registered listeners
Since: 1.0.0
Prop | Type | Description | Since |
---|---|---|---|
id |
int |
Message SMS id | 1.0.0 |
status |
string |
Delivery status, possible value are 'FAILED', 'SENT', or 'DELIVERED' | 1.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
id |
int |
SMS Message id | 1.0.0 |
sim |
int |
Device SIM index | 1.0.0 |
phone |
string |
Target phone number | 1.0.0 |
text |
string |
SMS Message | 1.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
send_sms |
PermissionState |
SEND_SMS Permission | 1.0.0 |
read_phone_state |
PermissionState |
READ_PHONE_STATE Permission | 1.0.0 |
Prop | Type |
---|---|
remove |
() => Promise<void> |
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'