Skip to content

Julias0/CapacitorSmsInboxReader

Repository files navigation

Capacitor Read SMS inbox plugin

A simple plugin around reading messages via capacitor

Contains two methods -

  • getAllMessages
  • getCount

This currently works in android only.

Feel free to submit a Pull request.

Android

Add <uses-permission android:name="android.permission.READ_SMS" /> to AndroidManifest.xml

Check for READ SMS permission before actually doing it - otherwise this throws an error.

Sample code -

  import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';

  const { SmsInboxReader } = Plugins;

  ....

  async readMessages() {
    await this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_SMS]);
    const isPermitted = this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_SMS);
    if (isPermitted) {
      const messages = await SmsInboxReader.getAllMessages();
      console.log(messages);
    }
  }

Note: Here I have used https://ionicframework.com/docs/native/android-permissions for checking android read sms permissions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published