notifications

Creator: coderz1093

Last updated:

Add to Cart

Description:

notifications

Notifications #

A plugin for monitoring notification on Android.
Install #
Add notifications as a dependency in pubspec.yaml. For help on adding as a dependency, view the documentation.
Add the following snippet of code inside the application tag of yours AndroidManifest.xml
...
<service
android:label="notifications"
android:name="dk.cachet.notifications.NotificationListener"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
</application>
copied to clipboard
Usage #
All incoming data points are streamed with a StreamSubscription which is set up by calling the listen() method on the notificationStream stream object.
Given a method onData(NotificationEvent event) the subscription can be set up as follows:
Notifications _notifications;
StreamSubscription<NotificationEvent> _subscription;
...
void onData(NotificationEvent event) {
print(event);
}

void startListening() {
_notifications = new Notifications();
try {
_subscription = _notifications!.notificationStream!.listen(onData);
} on NotificationException catch (exception) {
print(exception);
}
}
copied to clipboard
The stream can also be cancelled again by calling the cancel() method:
void stopListening() {
_subscription?.cancel();
}
copied to clipboard
The NotificationEvent provides:

the title
the message
package name
timestamp

of each notification.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.