flutter_notification_reader 1.0.1 copy "flutter_notification_reader: ^1.0.1" to clipboard
flutter_notification_reader: ^1.0.1 copied to clipboard

PlatformAndroid

a flutter plug-in to watch live notifications

flutter_notification_reader #

A Flutter application that demonstrates real-time notification monitoring and logging for Android devices. This app showcases the usage of the flutter_notification_reader plugin with an intuitive Material 3 interface.

Features #

  • Real-time Notification Monitoring: Listen to all incoming notifications in real-time
  • Package Filtering: Filter notifications by specific application packages
  • Toggle Mode: Easily switch between filtered and all-apps monitoring
  • Notification Logs: Display comprehensive notification details including package name, title, and text
  • Auto-Update: Live notification stream with instant UI updates

Installation #

1. Add Dependency #

Open the pubspec.yaml file located inside the app folder, and add flutter_notification_reader under dependencies:

dependencies:
  flutter:
    sdk: flutter
  flutter_notification_reader: <latest_version>

Then install it:

  • From the terminal: Run flutter pub get
  • From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec.yaml
  • From VS Code: Click Get Packages located in right side of the action ribbon at the top of pubspec.yaml

2. Register the Service in AndroidManifest.xml #

The plugin uses an Android system service to track notifications. To allow this service to run on your application, add the following code inside the Android manifest (android/app/src/main/AndroidManifest.xml), between the <application> tags:

<service
    android:exported="true"
    android:label="${applicationName}"
    android:icon="@mipmap/ic_launcher"
    android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
    android:name="dev.jimmy.flutter_notification_reader.NotificationReaderService">
    <intent-filter>
        <action android:name="android.service.notification.NotificationListenerService" />
    </intent-filter>
</service>

To enable automatic service start after device reboot, add this to your AndroidManifest.xml:

<receiver 
    android:name="dev.jimmy.flutter_notification_reader.NotificationReaderService"
    android:enabled="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

3. Add Required Permissions #

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

4. Update Minimum SDK Version #

Ensure your android/app/build.gradle has minimum SDK version 21 or higher:

android {
    ndkVersion = "27.0.12077973"
    defaultConfig {
        minSdkVersion 21
        // ...
    }
}

Usage #

Filter by Package #

The app comes pre-configured to monitor specific applications:

  • WhatsApp (com.whatsapp)
  • Telegram (org.telegram.messenger)

To add or modify target packages, edit the _targetPackages list in main.dart:

final _targetPackages = [
  {"name": "WhatsApp", "package": "com.whatsapp"},
  {"name": "Telegram", "package": "org.telegram.messenger"},
  // Add more apps here
];

Toggle Filter Mode #

Use the "Filter by Package" switch in the app bar to:

  • Enabled (ON): Monitor only notifications from target packages
  • Disabled (OFF): Monitor notifications from all applications

How It Works #

The application utilizes the flutter_notification_reader plugin to:

  1. Initialize Listener: Set up the notification listener service on app start
  2. Stream Notifications: Receive real-time notification events through a stream
  3. Filter Logic: Apply package-based filtering when enabled
  4. Update UI: Dynamically update the notification log list
  5. Persist Display: Maintain notification history until manually cleared

Architecture Overview #

┌─────────────────────────────────────┐
│   Android Notification System       │
└─────────────┬───────────────────────┘
              │
              │ Notification Posted
              ▼
┌─────────────────────────────────────┐
│  NotificationsHandlerService        │
│  (Android Service)                  │
└─────────────┬───────────────────────┘
              │
              │ Event Stream
              ▼
┌─────────────────────────────────────┐
│  FlutterNotificationListener        │
│  (Plugin)                           │
└─────────────┬───────────────────────┘
              │
              │ notificationStream
              ▼
┌─────────────────────────────────────┐
│  Flutter App UI                     │
│  - Filter Logic                     │
│  - Display Notifications            │
└─────────────────────────────────────┘

NotificationEvent Object #

Each notification event contains:

Field Type Description
package String Package name of the app
title String Notification title
content String Notification content text
timestamp DateTime Creation timestamp

Limitations #

  • Android Only: This app only works on Android devices (iOS does not support notification listening)
  • System Notifications: Some system-level notifications may not be accessible
  • Private Content: Some apps may not expose full notification content for privacy reasons
  • Background Restrictions: Aggressive battery optimization may stop the service

Privacy & Security #

⚠️ Important Privacy Notice

This application monitors notification content from other apps. Please be aware:

  • All notification data is processed locally on your device
  • No data is sent to external servers or third parties
  • Notification content may contain sensitive personal information
  • Use this application responsibly and in compliance with relevant privacy regulations
  • Do not use this application to access or monitor notifications without proper authorization

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Made with ❤️ DevJimmy