Android Notification Listener

This plugin ( only availaible on Android due to iOS restrictions ) will allow you to listen to any incoming notifications on an Android device running on Android APi level 21 or more . In another word you can read notifications coming from all the installed applications with deep details

Note: This pluggin is a Fork of the original plugin made by Cachet which has some bugs causing frequent crashes and is missing features and details, so I fixed it and added more features :)

Features

Here are the details you will get from a notification

  • The time Stamp
  • The package name
  • The package message
  • The package text
  • The package extra

Note: The PackageExtra contains more details about each individual notification. It is originally a bundle file. I converted it into a Json and give it to you as a Json String so if you need to use the PackageExtra you will have to json decode it as follow

var jsonDatax = json.decode(event.packageExtra);
print(jsonDatax);

You can refer the example folder for more detail

Here are the extra data you will get from the PackageExtra

  • android.title
  • android.reduced.images
  • android.template
  • android.text
  • android.foregroundApps
  • android.bigText

Android Setup

Register a service in the Android Manifest

The plugin uses an Android system service to track notifications. To allow this service to run on your application, the following code should be put inside the Android manifest, between the tags.

<service android:name="com.emilecode.android_notification_listener.AndroidNotificationListenerPlugin"
    android:label="notifications"
    android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
    <intent-filter>
        <action android:name="android.service.notification.NotificationListenerService" />
    </intent-filter>
</service>

Listen to notification events

AndroidNotificationListener _notifications;
StreamSubscription<NotificationEvent> _subscription;
events = notifications.stream.listen(onData);

Where the onData() method handles the incoming NotificationEvents. An example could be:

void onData(NotificationEvent event) => print(event.toString());

Conclusion

Thank you for using my package, if you have any question feel free to contact me on instagram or directly on my mail emile@emilecode.com

Here are my other packages

  • Ultimate Data Generator: generate realistic datas
  • Sliding Card: Animated card that slides down to reveal its hidden part
  • AdvFab: An Advanced floating action button that expands itself to reveal its hidden widget. It can also be used as an AnimatedbottomNavigationbar or just an AnimatedFloatingActionBar with the same expansion capabilities.

Libraries

android_notification_listener