Browse Source

Merge pull request #263 from provokateurin/feature/improve-push-notifications

Improve push notifications once more
pull/265/head
Kate 2 years ago committed by GitHub
parent
commit
a46d28bfca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/neon/neon/lib/src/utils/push_utils.dart

16
packages/neon/neon/lib/src/utils/push_utils.dart

@ -92,25 +92,27 @@ class PushUtils {
} }
final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud'; final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud';
var appName = localizations.appImplementationName(appID); String? appName = localizations.appImplementationName(appID);
if (appName == '') { if (appName == '') {
debugPrint('Missing app name for $appID'); debugPrint('Missing app name for $appID');
appName = appID; appName = null;
} }
final title = notification?.subject ?? pushNotification.subject.subject; final title = (notification?.subject ?? pushNotification.subject.subject)!;
final message = notification != null && notification.message != '' ? notification.message : null; final message = (notification?.message.isNotEmpty ?? false) ? notification!.message : null;
final when = notification != null ? DateTime.parse(notification.datetime) : null;
await localNotificationsPlugin.show( await localNotificationsPlugin.show(
_getNotificationID(instance, pushNotification), _getNotificationID(instance, pushNotification),
message != null ? '$appName: $title' : appName, message != null && appName != null ? '$appName: $title' : title,
message ?? title, message,
NotificationDetails( NotificationDetails(
android: AndroidNotificationDetails( android: AndroidNotificationDetails(
appID, appID,
appName, appName ?? appID,
subText: accounts.length > 1 && account != null ? account.client.humanReadableID : null, subText: accounts.length > 1 && account != null ? account.client.humanReadableID : null,
groupKey: 'app_$appID', groupKey: 'app_$appID',
icon: '@mipmap/ic_launcher', icon: '@mipmap/ic_launcher',
when: when?.millisecondsSinceEpoch,
color: themePrimaryColor, color: themePrimaryColor,
category: pushNotification.type == 'voip' ? AndroidNotificationCategory.call : null, category: pushNotification.type == 'voip' ? AndroidNotificationCategory.call : null,
importance: Importance.max, importance: Importance.max,

Loading…
Cancel
Save