From 37ab6c541ae4b01ba10338b59ce5ebc5cb2ca374 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 19 Apr 2023 20:05:58 +0200 Subject: [PATCH 1/2] neon: Set timestamp of push notification --- packages/neon/neon/lib/src/utils/push_utils.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index 9797efbd..e1621ac0 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -99,6 +99,7 @@ class PushUtils { } final title = notification?.subject ?? pushNotification.subject.subject; final message = notification != null && notification.message != '' ? notification.message : null; + final when = notification != null ? DateTime.parse(notification.datetime) : null; await localNotificationsPlugin.show( _getNotificationID(instance, pushNotification), @@ -111,6 +112,7 @@ class PushUtils { subText: accounts.length > 1 && account != null ? account.client.humanReadableID : null, groupKey: 'app_$appID', icon: '@mipmap/ic_launcher', + when: when?.millisecondsSinceEpoch, color: themePrimaryColor, category: pushNotification.type == 'voip' ? AndroidNotificationCategory.call : null, importance: Importance.max, From 8d5dcb9bb6fcd61a0ff319394bdddaa12b09c1be Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 19 Apr 2023 20:06:43 +0200 Subject: [PATCH 2/2] neon: Display push notification titles in a better way --- packages/neon/neon/lib/src/utils/push_utils.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index e1621ac0..ed407d15 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -92,23 +92,23 @@ class PushUtils { } final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud'; - var appName = localizations.appImplementationName(appID); + String? appName = localizations.appImplementationName(appID); if (appName == '') { debugPrint('Missing app name for $appID'); - appName = appID; + appName = null; } - final title = notification?.subject ?? pushNotification.subject.subject; - final message = notification != null && notification.message != '' ? notification.message : null; + final title = (notification?.subject ?? pushNotification.subject.subject)!; + final message = (notification?.message.isNotEmpty ?? false) ? notification!.message : null; final when = notification != null ? DateTime.parse(notification.datetime) : null; await localNotificationsPlugin.show( _getNotificationID(instance, pushNotification), - message != null ? '$appName: $title' : appName, - message ?? title, + message != null && appName != null ? '$appName: $title' : title, + message, NotificationDetails( android: AndroidNotificationDetails( appID, - appName, + appName ?? appID, subText: accounts.length > 1 && account != null ? account.client.humanReadableID : null, groupKey: 'app_$appID', icon: '@mipmap/ic_launcher',