capacitor-sms-watcher
v0.0.1
Published
A Capacitor plugin that listens to all SMS or from a specific Sender ID, extracts message content, and returns the data for use in your app.
Readme
capacitor-sms-watcher
A Capacitor plugin that listens to all SMS or from a specific Sender ID, extracts message content, and returns the data for use in your app.
Install
npm install capacitor-sms-watcher
npx cap syncAPI
listenToAll()listenTo(...)getSMS(...)getSMSByDate(...)addListener('onSmsReceivedAll', ...)addListener('onSmsReceivedFiltered', ...)- Interfaces
listenToAll()
listenToAll() => Promise<void>Listen for every incoming SMS message. Subscribe to the "onSmsReceivedAll" event.
listenTo(...)
listenTo(options: { senderId: string; }) => Promise<void>Listen for SMS messages from a specific sender. Subscribe to the "onSmsReceivedFiltered" event.
| Param | Type |
| ------------- | ---------------------------------- |
| options | { senderId: string; } |
getSMS(...)
getSMS(options: { senderId: string; limit?: number; }) => Promise<{ messages: SmsMessage[]; }>Retrieve the last N SMS messages from the device inbox for a specific sender.
| Param | Type |
| ------------- | -------------------------------------------------- |
| options | { senderId: string; limit?: number; } |
Returns: Promise<{ messages: SmsMessage[]; }>
getSMSByDate(...)
getSMSByDate(options: { senderId: string; epochDateLimit?: string; }) => Promise<{ messages: SmsMessage[]; }>Retrieve SMS messages from the device inbox for a specific sender that have a date greater than or equal to the given epoch timestamp.
| Param | Type |
| ------------- | ----------------------------------------------------------- |
| options | { senderId: string; epochDateLimit?: string; } |
Returns: Promise<{ messages: SmsMessage[]; }>
addListener('onSmsReceivedAll', ...)
addListener(eventName: 'onSmsReceivedAll', listenerFunc: (data: SmsMessage) => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | -------------------------------------------------------------------- |
| eventName | 'onSmsReceivedAll' |
| listenerFunc | (data: SmsMessage) => void |
Returns: Promise<PluginListenerHandle>
addListener('onSmsReceivedFiltered', ...)
addListener(eventName: 'onSmsReceivedFiltered', listenerFunc: (data: SmsMessage) => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | -------------------------------------------------------------------- |
| eventName | 'onSmsReceivedFiltered' |
| listenerFunc | (data: SmsMessage) => void |
Returns: Promise<PluginListenerHandle>
Interfaces
SmsMessage
| Prop | Type |
| ------------- | ------------------- |
| id | string |
| sender | string |
| date | number |
| message | string |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
