nix notification manager only use title, body is unsafe
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
1a4dccf44a
commit
5e7272b15a
|
@ -4,8 +4,11 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:cwtch/main.dart';
|
import 'package:cwtch/main.dart';
|
||||||
import 'package:win_toast/win_toast.dart';
|
import 'package:win_toast/win_toast.dart';
|
||||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
//import 'package:desktop_notifications/desktop_notifications.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
import 'package:flutter_local_notifications_linux/flutter_local_notifications_linux.dart';
|
||||||
|
import 'package:flutter_local_notifications_linux/src/model/hint.dart';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import 'config.dart';
|
import 'config.dart';
|
||||||
|
@ -80,18 +83,14 @@ class NixNotificationManager implements NotificationsManager {
|
||||||
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
final MacOSInitializationSettings initializationSettingsMacOS = MacOSInitializationSettings(defaultPresentSound: true);
|
final MacOSInitializationSettings initializationSettingsMacOS = MacOSInitializationSettings(defaultPresentSound: true);
|
||||||
final LinuxInitializationSettings initializationSettingsLinux =
|
final LinuxInitializationSettings initializationSettingsLinux =
|
||||||
LinuxInitializationSettings(
|
LinuxInitializationSettings(defaultActionName: 'Open notification', defaultIcon: AssetsLinuxIcon('assets/knott.png'), defaultSuppressSound: true);
|
||||||
defaultActionName: 'Open notification',
|
|
||||||
defaultIcon: AssetsLinuxIcon('assets/knott.png'),
|
|
||||||
defaultSuppressSound: true
|
|
||||||
);
|
|
||||||
|
|
||||||
final InitializationSettings initializationSettings = InitializationSettings(android: null, iOS: null, macOS: initializationSettingsMacOS, linux: initializationSettingsLinux);
|
final InitializationSettings initializationSettings = InitializationSettings(android: null, iOS: null, macOS: initializationSettingsMacOS, linux: initializationSettingsLinux);
|
||||||
|
|
||||||
flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<MacOSFlutterLocalNotificationsPlugin>()?.requestPermissions(
|
flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<MacOSFlutterLocalNotificationsPlugin>()?.requestPermissions(
|
||||||
alert: true,
|
alert: true,
|
||||||
badge: true,
|
badge: false,
|
||||||
sound: true,
|
sound: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
scheduleMicrotask(() async {
|
scheduleMicrotask(() async {
|
||||||
|
@ -99,6 +98,13 @@ class NixNotificationManager implements NotificationsManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> notify(String message, String profile, int conversationId) async {
|
||||||
|
// Warning: Only use title field on Linux, body field will render links as clickable
|
||||||
|
await flutterLocalNotificationsPlugin.show(0, message, '', NotificationDetails(linux: LinuxNotificationDetails(suppressSound: true, category: LinuxNotificationCategory.imReceived())),
|
||||||
|
payload: jsonEncode(NotificationPayload(profile, conversationId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notification click response function, triggers ui jump to conversation
|
||||||
void selectNotification(String? payloadJson) async {
|
void selectNotification(String? payloadJson) async {
|
||||||
if (payloadJson != null) {
|
if (payloadJson != null) {
|
||||||
Map<String, dynamic> payloadMap = jsonDecode(payloadJson);
|
Map<String, dynamic> payloadMap = jsonDecode(payloadJson);
|
||||||
|
@ -106,10 +112,6 @@ class NixNotificationManager implements NotificationsManager {
|
||||||
notificationSelectConvo(payload.profileOnion, payload.convoId);
|
notificationSelectConvo(payload.profileOnion, payload.convoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> notify(String message, String profile, int conversationId) async {
|
|
||||||
await flutterLocalNotificationsPlugin.show(0, 'Cwtch', message, null, payload: jsonEncode(NotificationPayload(profile, conversationId)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationsManager newDesktopNotificationsManager(Future<void> Function(String profileOnion, int convoId) notificationSelectConvo) {
|
NotificationsManager newDesktopNotificationsManager(Future<void> Function(String profileOnion, int convoId) notificationSelectConvo) {
|
||||||
|
|
13
pubspec.lock
13
pubspec.lock
|
@ -189,14 +189,7 @@ packages:
|
||||||
name: dbus
|
name: dbus
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.8"
|
version: "0.7.1"
|
||||||
desktop_notifications:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: desktop_notifications
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.6.0"
|
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -269,7 +262,7 @@ packages:
|
||||||
name: flutter_local_notifications_linux
|
name: flutter_local_notifications_linux
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.1+1"
|
version: "0.4.2"
|
||||||
flutter_local_notifications_platform_interface:
|
flutter_local_notifications_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -824,7 +817,7 @@ packages:
|
||||||
name: xdg_directories
|
name: xdg_directories
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0"
|
version: "0.2.0+1"
|
||||||
xml:
|
xml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -42,7 +42,6 @@ dependencies:
|
||||||
file_picker_desktop: ^1.1.0
|
file_picker_desktop: ^1.1.0
|
||||||
url_launcher: ^6.0.18
|
url_launcher: ^6.0.18
|
||||||
window_manager: ^0.1.4
|
window_manager: ^0.1.4
|
||||||
desktop_notifications: 0.6.0
|
|
||||||
win_toast: ^0.0.2
|
win_toast: ^0.0.2
|
||||||
flutter_local_notifications: 9.3.2
|
flutter_local_notifications: 9.3.2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue