forked from Nexus/nexus
smarter notif logic
This commit is contained in:
parent
74207e405b
commit
0122feae1d
2 changed files with 47 additions and 24 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import "dart:convert";
|
||||
import "dart:io";
|
||||
|
||||
import "package:flutter_local_notifications/flutter_local_notifications.dart";
|
||||
// ignore: implementation_imports
|
||||
import "package:flutter_local_notifications_linux/src/model/hint.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/event.dart";
|
||||
|
||||
class NotificationsController
|
||||
extends AsyncNotifier<FlutterLocalNotificationsPlugin> {
|
||||
|
|
@ -26,7 +28,11 @@ class NotificationsController
|
|||
linux: .new(defaultActionName: "Open"),
|
||||
),
|
||||
onDidReceiveNotificationResponse: (details) {
|
||||
print(details.data);
|
||||
if (details.payload case final payload?) {
|
||||
final event = ref.watch(
|
||||
EventController.provider(.fromJson(json.decode(payload))),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -75,8 +81,6 @@ class NotificationsController
|
|||
"Messages",
|
||||
largeIcon: icon == null ? null : FilePathAndroidBitmap(icon.path),
|
||||
),
|
||||
iOS: .new(),
|
||||
macOS: .new(),
|
||||
linux: .new(
|
||||
customHints: icon == null
|
||||
? null
|
||||
|
|
@ -87,6 +91,9 @@ class NotificationsController
|
|||
),
|
||||
],
|
||||
),
|
||||
// TODO: See if icons can be added to iOS, macOS, and Windows notifications (#68)
|
||||
iOS: .new(),
|
||||
macOS: .new(),
|
||||
windows: .new(),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue