Flutter plugin to listen to all incoming notifications (posted or removed) with the possibility to reply to them

Overview

notification_listener_service

A flutter plugin for interacting with Notification Service in Android.

NotificationListenerService is a service that receives calls from the system when new notifications are posted or removed,

for more info check NotificationListenerService

Installation and usage

Add package to your pubspec:

dependencies:
  notification_listener_service: any # or the latest version on Pub

Inside AndroidManifest add this to bind notification service with your application

    ...
    <service android:label="notifications" android:name="notification.listener.service.NotificationListener" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
        <intent-filter>
            <action android:name="android.service.notification.NotificationListenerService" />
        </intent-filter>
    </service>
    ...
</application>

USAGE

 /// check if notification permession is enebaled
 final bool status = await NotificationListenerService.isPermissionGranted();

 /// request notification permission
 /// it will open the notifications settings page and return `true` once the permission granted.
 final bool status = await NotificationListenerService.requestPermission();

 /// stream the incoming notification events
  NotificationListenerService.notificationsStream.listen((event) {
    log("Current notification: $event");
  });

The ServiceNotificationEvent provides:

  /// the notification id
  int? id;

  /// check if we can reply the Notification
  bool? canReply;

  /// if the notification has an extras image
  bool? hasExtrasPicture;

  /// if the notification has been removed
  bool? hasRemoved;

  /// notification extras image
  /// To display an image simply use the [Image.memory] widget.
  Uint8List? extrasPicture;

  /// notification package name
  String? packageName;

  /// notification title
  String? title;

  /// the notification app icon
  /// To display an image simply use the [Image.memory] widget.
  Uint8List? notificationIcon;

  /// the content of the notification
  String? content;

  /// send a direct message reply to the incoming notification
  Future<bool> sendReply(String message)

To reply to a notification provides:

  try {
    await event.sendReply("This is an auto response");
  } catch (e) {
    log(e.toString());
  }

Exemple of the app on foreground

Find the exemple app Here

Screenshots

Comments
  • Error while trying to run

    Error while trying to run

    Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present] Error launching application on LE2101.

    opened by akhilgorantala 6
  • Not working in background

    Not working in background

    Hello dear.. First of all thanks for providing us such a great plugin which listen the incoming calls it works perfectly when we are in app but when we put the app in background(exit app) so it's doesn't show the actual data instead of actual data it so the following

    D/skia ( 3443): Encode PNG Singlethread processname=com. : 19276 us, width=189, height=189 W/FlutterJNI( 3443): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: x-slayer/notifications_event. Response ID: 25

    Can u please help me out to solve this issue..

    opened by sadiq61651 4
  • New Feature Requests

    New Feature Requests

    hey @X-SLAYER its a great package and I am expecting more features from your side.

    • Add background activity even if the app reboots, the app again starts automatically
    • Add checks for deleted message as you already have done for the message when they are removed
    • when a notification event triggers and at that time there are messages that were sent to the device before we start listening then the package lists all of them. I want it show them in seperate functions. I mean its must show only one notification that just occurs in a seperate function and showing the other list of prevoius message must be done in other function. I just need that when a notification occurs package only show just that event at that time instead of load all the message from notification bar.
    enhancement 
    opened by ZiaUrRahmam 3
  • It doesn't work in production mode - Android

    It doesn't work in production mode - Android

    It doesn't work for me when I compile and upload it to play console and test it internally

    flutter build appbundle --obfuscate --split-debug-info=debug-info

    Package: notification_listener_service: ^0.3.1 flutter_foreground_task: ^3.8.1

    Flutter: v3.0.5 minSdkVersion 23 targetSdkVersion 31

    AndroidManifest.xml `

    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE " />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
    

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id"/>
    
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxx~xxxxxxxxxxx"/>
    
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/NormalTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- android:theme="@style/LaunchTheme" -->
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
    
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
    
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
    
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    
        <meta-data
            android:name="com.google.firebase.messaging.default_notificacion_icon"
            android:resource="@mipmap/ic_launcher" />
    
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorPrimary" />
    
        <!-- Notification Service -->
        <service
            android:label="TesterInter"
            android:name="notification.listener.service.NotificationListener"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
            android:exported="false">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService" />
            </intent-filter>
        </service>
        <service android:name="com.pravera.flutter_foreground_task.service.ForegroundService" />
        <!-- Notification Service -->
    </application>
    

    `

    opened by jack1230 1
  • Get App Icon

    Get App Icon

    I am using Xiaomi Mi 10 Miui 13.0.7.0 Android 12 i got this error after listening to the notification. I think your library has a problem when taking out the App Icon

    Error!

    W/System.err(19775): android.content.pm.PackageManager$NameNotFoundException: com.facebook.orca W/System.err(19775): at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:471) W/System.err(19775): at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:460) W/System.err(19775): at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:1614) W/System.err(19775): at notification.listener.service.NotificationListener.getSmallIcon(NotificationListener.java:83) W/System.err(19775): at notification.listener.service.NotificationListener.handleNotification(NotificationListener.java:44) W/System.err(19775): at notification.listener.service.NotificationListener.onNotificationPosted(NotificationListener.java:31) W/System.err(19775): at android.service.notification.NotificationListenerService.onNotificationPosted(NotificationListenerService.java:444) W/System.err(19775): at android.service.notification.NotificationListenerService$MyHandler.handleMessage(NotificationListenerService.java:2305) W/System.err(19775): at android.os.Handler.dispatchMessage(Handler.java:106) W/System.err(19775): at android.os.Looper.loopOnce(Looper.java:210) W/System.err(19775): at android.os.Looper.loop(Looper.java:299) W/System.err(19775): at android.app.ActivityThread.main(ActivityThread.java:8293) W/System.err(19775): at java.lang.reflect.Method.invoke(Native Method) W/System.err(19775): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) W/System.err(19775): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

    opened by toilathor 0
  • New Feature Request - Album Art

    New Feature Request - Album Art

    Hi, I am using a similar plugin in React Native. Among its features is the album art. Can you add the same feature? RN example: https://github.com/leandrosimoes/react-native-android-notification-listener/issues/21

    Feature Request 
    opened by eticaretmuhendisi 0
Owner
Iheb Briki
I'm a full-stack developer and mainly use Flutter, ReactJs, MeteorJs & .NET. trying to be better every day @PixeliumTN
Iheb Briki
Mint 0.1.1 public release, HWID System removed. Feel free to use. (Note: for all of u thinking its ratted; its not.)

Mint By: zPrestige_ | ! zPrestige_#1514 | git Kambing | dragonhacker32_#3091 | git FB | FB#7334 | git ZenovJB | Zenov#0603 | git Support no support No

null 17 Dec 2, 2022
Android Auto Apps Downloader (AAAD) is an app for Android Phones that downloads popular Android Auto 3rd party apps and installs them in the correct way to have them in Android Auto.

Android Auto Apps Downloader (AAAD) is an app for Android Phones that downloads popular Android Auto 3rd party apps and installs them in the correct way to have them in Android Auto.

Gabriele Rizzo 865 Jan 2, 2023
he removed me from the git so might as well leaked it. (src from 2/7/21)

perry-phobos-src leak src. (src from 2/7/21) Why? to avoid ppl thinking its phobos 2.0.0, he also removed my git access Not Recommended dont use the s

null 14 Dec 2, 2022
Tasks Planner : A minimalist collaborative app for scheduling and managing your tasks with the team and getting notifications through discord.

Tasks Planner ✨ Overview Tasks planner is a minimalist collaborative app for planning and managing your tasks with the team and get notifications thro

MILIARI Adnane 7 Dec 1, 2022
This repo contains all the materials for placement as well as Practical lab codes for all subjects and notes. For students graduating in 2023

UEMK_PLACEMENT_2023 This repo contains all the materials for placement as well as Practical lab codes for all subjects and notes. For students graduat

Shambashib Majumdar 8 Mar 5, 2022
A Java agent that disables platform features you don't use, before an attacker uses them against you.

aegis4j Avoid the NEXT Log4Shell vulnerability! The Java platform has accrued a number of features over the years. Some of these features are no longe

Daniel Gredler 14 Jan 11, 2022
Allows acquiring of vanilla/mod assets at runtime instead of including them in builds potentially violating licenses

AssetMover Allows acquiring of vanilla/mod assets at runtime instead of including them in builds potentially violating licenses. Features: Downloading

Cleanroom 5 Nov 26, 2022
Run Java plugins without compiling them

Run Java plugins without compiling them! Usage Under plugins/SkriptJava, you can put your .java files to run when the server is up and loaded. This pl

Rance Andres 5 Sep 5, 2022
A script that downloads wallpapers from the subreddit r/wallpapers and then sets them on your Windows machine.

Wallpaper Downloader ?? This script takes the most voted wallpaper in the subreddit r/wallpapers in 24 hours, downloads the .json of that page, parses

404a10 1 May 15, 2022
A manager tool to categorize game assets such as images and sounds/music. The tool enables you to tag these files, so that finding them by tags allows fast searches.

BtAssetManager This application allows you to easily categorize large amounts of image and sound files. You can apply tags to each individual file to

null 21 Sep 15, 2022
A Velocity proxy plugin for Minecraft server discovery in k8s. All discovered servers are automatically added to the Velocity proxy.

kryo-server-discovery This plugin connects minecraft servers to a velocity proxy within Kubernetes. The service account in the namespace which the pro

Kryonite 9 Sep 13, 2022
trying to create a plugin using the spigot api! this plugin will be responsible for delivering the products according to the settings!

KettraShop "simples plugin de ativação de produtos da loja, dentro do Minecraft" ⚙️ Configurações caso você não tenha uma loja virtual para seu servid

SEBASTIAN JN ฅ^•ﻌ•^ฅ 4 Nov 2, 2022
Tuya 37 Dec 26, 2022
📊It includes all the work done during the Java-React Bootcamp.

?? Java + React Bootcamp ?? Part 1 - Java Part 2 - React ?? Lecture Class: Youtube ?? Instructor: Engin Demirog ?? Course Materials: Kodlama.io Bootca

İlknur Sucaklı 20 Jun 21, 2022
All development related with the ONLYONE token.

onlyone All development related with the Onlyone Finance. ONLYONE Token Total Supply: 1 Contract creation: https://bscscan.com/tx/0x1becbd78297f267dec

Onlyone Finance 73 Jan 1, 2023
Jornada Big Tech: I will have 3 months to study and prepare myself for the Big Tech interviews. Repository containing all my study material.

Jornada Big Tech (Big Tech Journey) Jornada Big Tech: I will have 3 months to study and prepare myself for the Big Tech interviews. Repository contain

Camila Maia 87 Dec 8, 2022
All I know about Spring as a Spring Boot app

All about Spring This repository contains all the knowledge I have and all the things I can do with Spring You can download v1.0.0 java-doc here In th

Soroush Mehrad 12 Jul 16, 2022
trace all binder-funcion calls on android-platform

BinderHackDemo trace all binder-funcion calls on android-platform 该demo展示了如何使用libbinderhack.so模块,trace-app自身进程binder调用情况 您可以通过该次提交,查看如何使用libbinderhack

null 4 Dec 25, 2021
All the Android-Java Projects in Single Repository

Android Java Projects List of Projects Factorial Calculator Multiplication Table Web App Steps to Run the Applications Clone this Repository Create a

Rajan Gautam 2 Oct 10, 2022