0.0.2 • Published 11 months ago

sms-getter v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

sms-getter

Read sms messages for capacitor (Android only)

Install

npm install sms-getter
npx cap sync

Usage

import { SmsGetter } from 'sms-getter';

async startWatchingSms() {
    let permission = false;
    try {
      await SmsGetter.startWatch();
      permission = true;
      console.log('Started watching for incoming SMS');
    } catch (error) {
      permission = false;
      console.error('Error starting SMS watch:', error);
    }

    if (permission) {
      // Listen for SMS events
      SmsGetter.addListener('smsReceived', (sms) => {
        console.log(sms);
      });
    }
  }

API

startWatch()

startWatch() => Promise<void>

Starts the SMS receiver to watch for incoming SMS.


addListener('smsReceived', ...)

addListener(eventName: 'smsReceived', listenerFunc: (data: { sender: string; message: string; }) => void) => Promise<PluginListenerHandle>

Adds an event listener for the 'smsReceived' event.

ParamTypeDescription
eventName'smsReceived'The event name, which is 'smsReceived'.
listenerFunc(data: { sender: string; message: string; }) => voidThe function to call when the SMS is received.

Returns: Promise<PluginListenerHandle>


Interfaces

PluginListenerHandle

PropType
remove() => Promise<void>
0.0.2

11 months ago

0.0.1

11 months ago