0.2.9 • Published 1 year ago

sms-retriever v0.2.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

📱 SMS Retriever

Effortlessly retrieve OTPs from SMS in your Capacitor apps.

npm npm license

📦 Install

To install the sms-retriever plugin, run the following commands:

npm install sms-retriever
npx cap sync

📖 API

Defines the interface for the SmsReaderPlugin.

readSMS(...)

readSMS(options: ReadSMSOptions) => Promise<ReadSMSResult>

Reads the OTP from SMS messages based on the provided search string.

ParamTypeDescription
optionsReadSMSOptions- An object containing the search string.

Returns: Promise<ReadSMSResult>


startWatching(...)

startWatching(options: ReadSMSOptions) => Promise<ReadSMSResult>

Starts watching for SMS messages to read the OTP based on the provided search string.

ParamTypeDescription
optionsReadSMSOptions- An object containing the search string.

Returns: Promise<ReadSMSResult>


stopWatching()

stopWatching() => Promise<void>

Stops watching for SMS messages.


Interfaces

ReadSMSResult

Represents the result of reading SMS.

PropTypeDescription
otpstringThe OTP extracted from the SMS.

ReadSMSOptions

Represents the options for reading SMS.

PropTypeDescription
searchStringstringThe search string used to find the OTP in the SMS.

💡 Usage Example

Here's a quick example of how to use the sms-retriever plugin in your Capacitor app:

import { SmsReader } from 'sms-retriever';

async function watchForOTP() {
  try {
    const result = await SmsReader.startWatching({ searchString: "OTP: " });
    console.log('Received OTP:', result.otp);
    
    // Optionally stop watching after receiving OTP
    await stopWatchingForOTP();
  } catch (error) {
    console.error('Error watching for OTP:', error);
  }
}

async function stopWatchingForOTP() {
  try {
    await SmsReader.stopWatching();
    console.log('Stopped watching for OTP');
  } catch (error) {
    console.error('Error stopping SMS watcher:', error);
  }
}

// Start watching for OTP
watchForOTP();

With this setup, the plugin will start watching for SMS messages that contain the specified search string, extract the OTP, and stop watching once the OTP is retrieved.

📝 License

This project is licensed under the MIT License. See the LICENSE file for more details.

0.2.9

1 year ago

0.2.8

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago