@quipuscore/capacitor-sms
v0.0.1
Published
Capacitor plugin for reading and syncing SMS messages on Android devices.
Maintainers
Readme
Capacitor SMS Plugin
A Capacitor plugin to read and sync SMS messages on Android devices.
Note: This plugin is Android-only. SMS reading is not supported on iOS.
Installation
npm install @quipuscore/capacitor-sms
npx cap syncRequirements
- Capacitor 7+
- Android API level 22+ (Android 5.1+)
Configuration
Android
Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.INTERNET" />Usage
Initialize the plugin
import { SmsPlugin } from '@quipuscore/capacitor-sms';
// Initialize with your API token
await SmsPlugin.initialize({ token: 'YOUR_API_TOKEN' });Read and sync SMS messages
// Read SMS messages and sync with your backend in a single operation
try {
const result = await SmsPlugin.collectAndSync({
userId: 'user123',
deviceId: 'device456'
});
console.log(`Successfully processed ${result.messages.length} messages`);
} catch (error) {
console.error('Error reading or syncing SMS:', error);
}API
Public interface for the SMS plugin - exposing initialize, collectAndSync, and linkUserIdWithDevice methods
initialize(...)
initialize(options: InitializeOptions) => Promise<InitializeResult>Initialize the SMS plugin with a token
| Param | Type | Description |
| ------------- | --------------------------------------------------------------- | ------------------------------------------- |
| options | InitializeOptions | Options containing the authentication token |
Returns: Promise<InitializeResult>
collectAndSync(...)
collectAndSync(options: CollectAndSyncOptions) => Promise<SyncSmsResult>Collect SMS messages and sync them to the server in one operation
| Param | Type | Description |
| ------------- | ----------------------------------------------------------------------- | -------------------------------------- |
| options | CollectAndSyncOptions | Options containing userId and deviceId |
Returns: Promise<SyncSmsResult>
linkUserIdWithDevice(...)
linkUserIdWithDevice(options: LinkUserIdWithDeviceOptions) => Promise<LinkUserIdWithDeviceResult>Link a user ID with a device ID
| Param | Type | Description |
| ------------- | ----------------------------------------------------------------------------------- | -------------------------------------- |
| options | LinkUserIdWithDeviceOptions | Options containing userId and deviceId |
Returns: Promise<LinkUserIdWithDeviceResult>
Interfaces
InitializeResult
| Prop | Type |
| ------------- | -------------------- |
| success | boolean |
| message | string |
InitializeOptions
| Prop | Type | Description |
| -------------- | ------------------- | ---------------------------------------------------------------------------------------- |
| clientId | string | Client ID for identification |
| token | string | API token for authentication - this also determines the environment (sandbox/production) |
SyncSmsResult
| Prop | Type |
| ------------- | -------------------- |
| success | boolean |
| message | string |
CollectAndSyncOptions
| Prop | Type | Description |
| -------------------- | ------------------- | ------------------------ |
| deviceId | string | |
| userId | string | Optional user ID |
| identityNumber | string | Optional identity number |
| identityType | string | Optional identity type |
LinkUserIdWithDeviceResult
| Prop | Type |
| ------------- | -------------------- |
| success | boolean |
| message | string |
LinkUserIdWithDeviceOptions
| Prop | Type | Description |
| -------------- | ------------------- | ------------------------------- |
| userId | string | User ID to link with the device |
| deviceId | string | Device ID to link with the user |
License
MIT
