https://github.com/x-slayer/notification_listener_service
Flutter plugin to listen to all incoming notifications (posted or removed) with the possibility to reply to them
https://github.com/x-slayer/notification_listener_service
android flutter notification-service notifications
Last synced: about 1 month ago
JSON representation
Flutter plugin to listen to all incoming notifications (posted or removed) with the possibility to reply to them
- Host: GitHub
- URL: https://github.com/x-slayer/notification_listener_service
- Owner: X-SLAYER
- License: mit
- Created: 2022-04-19T19:07:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-21T07:28:33.000Z (11 months ago)
- Last Synced: 2024-12-18T10:41:31.004Z (10 months ago)
- Topics: android, flutter, notification-service, notifications
- Language: Dart
- Homepage: https://pub.dev/packages/notification_listener_service
- Size: 107 KB
- Stars: 21
- Watchers: 3
- Forks: 25
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://developer.android.com/reference/android/service/notification/NotificationListenerService)
### Installation and usage
Add package to your pubspec:
```yaml
dependencies:
notification_listener_service: any # or the latest version on Pub
```Inside AndroidManifest add this to bind notification service with your application
```
```
### USAGE
```dart
/// 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:
```dart
/// the notification id
int? id;/// check if we can reply the Notification
bool? canReply;/// if the notification has an extras image
bool? haveExtraPicture;/// if the notification has been removed
bool? 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 name
String? packageName;/// notification title
String? title;/// the notification app icon
/// To display an image simply use the [Image.memory] widget.
Uint8List? appIcon;/// the content of the notification
String? content;/// send a direct message reply to the incoming notification
Future sendReply(String message)```
To reply to a notification provides:
```dart
try {
await event.sendReply("This is an auto response");
} catch (e) {
log(e.toString());
}```
## Example of the app on foregroundFind the exemple app [Here](https://github.com/X-SLAYER/foreground_plugins_test)
## Screenshots