/// check if notification permession is enebaledfinalbool status = awaitNotificationListenerService.isPermissionGranted();
/// request notification permission/// it will open the notifications settings page and return `true` once the permission granted.finalbool status = awaitNotificationListenerService.requestPermission();
/// stream the incoming notification eventsNotificationListenerService.notificationsStream.listen((event) {
log("Current notification: $event");
});
The ServiceNotificationEvent provides:
/// the notification idint? id;
/// check if we can reply the Notificationbool? canReply;
/// if the notification has an extras imagebool? haveExtraPicture;
/// if the notification has been removedbool? hasRemoved;
/// notification extras image/// To display an image simply use the [Image.memory] widget.Uint8List? extrasPicture;
/// notification large icon/// To display an image simply use the [Image.memory] widget.Uint8List? largeIcon;
/// notification package nameString? packageName;
/// notification titleString? title;
/// the notification app icon/// To display an image simply use the [Image.memory] widget.Uint8List? appIcon;
/// the content of the notificationString? content;
/// send a direct message reply to the incoming notificationFuture<bool> sendReply(String message)
To reply to a notification provides:
try {
await event.sendReply("This is an auto response");
} catch (e) {
log(e.toString());
}