From 6011e9b3c41597862cd1a3d9649cca19e2089d47 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 30 Jul 2022 13:23:13 +0200 Subject: [PATCH] chore: Make push helper more stable --- lib/utils/push_helper.dart | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 8fa532ca..beb8fcf9 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:ui'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; @@ -44,7 +45,17 @@ Future pushHelper( 0, l10n?.newMessageInFluffyChat, l10n?.openAppToReadMessages, - null, + NotificationDetails( + iOS: const IOSNotificationDetails(), + android: AndroidNotificationDetails( + AppConfig.pushNotificationsChannelId, + AppConfig.pushNotificationsChannelName, + channelDescription: AppConfig.pushNotificationsChannelDescription, + number: notification.counts?.unread, + ticker: l10n!.unreadChats(notification.counts?.unread ?? 1), + importance: Importance.max, + priority: Priority.high, + )), ); rethrow; } @@ -122,8 +133,14 @@ Future _tryPushHelper( height: 126, ) .toString(); - final avatarFile = - avatar == null ? null : await DefaultCacheManager().getSingleFile(avatar); + File? avatarFile; + try { + avatarFile = avatar == null + ? null + : await DefaultCacheManager().getSingleFile(avatar); + } catch (e, s) { + Logs().e('Unable to get avatar picture', e, s); + } final id = await mapRoomIdToInt(event.room.id);