Flutter Android SMS Reader

Pub Version Pub Likes Pub Points Popularity

A Flutter plugin to read SMS messages on Android. Supports inbox, sent, and draft messages with pagination, search, streaming of incoming messages, and permission handling.

⚠️ This plugin is Android-only. iOS does not allow SMS access due to platform restrictions.


πŸš€ Features

Feature Description
βœ… Fetch All Messages Access all SMS on the device
βœ… Filter by Type Fetch only inbox, sent, or draft messages
βœ… Pagination Support Lazy loading of messages
βœ… Search SMS Filter by keyword or phone number
βœ… Message Count Total number of messages per type
βœ… Observe New SMS Stream new incoming messages in real-time
βœ… Read Permissions Auto-handle permission requests
βœ… Dual SIM Support (WIP) Read SIM info (planned)
βœ… Export to JSON Easily convert messages for sharing/storage

πŸ›  Installation

Add this to your pubspec.yaml:

dependencies:
  android_sms_reader: ^<Latest-Version>

Then run:

flutter pub get

πŸ“² Usage

import 'package:android_sms_reader/android_sms_reader.dart';

void init() async {
  bool granted = await SmsReader.requestPermissions();
  if (!granted) {
    // handle permission
    return;
  }

  final messages = await SmsReader.fetchMessages(
    type: SmsType.inbox,
    start: 0,
    count: 50,
    query: 'OTP',
  );

  final count = await SmsReader.getMessageCount(SmsType.sent);

  SmsReader.observeIncomingMessages().listen((sms) {
    print("Received: ${sms.body}");
  });
}

❗ Android Permissions

Ensure you add these to your AndroidManifest.xml:


<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />

❌ iOS Support

iOS does not support reading SMS messages. This plugin returns UnsupportedError on iOS platforms.

Libraries

android_sms_reader