From e300048d3bcffdc118e9955871ea9e90cca71998 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 28 May 2021 20:32:52 +0200 Subject: [PATCH] fix: No push setup --- CHANGELOG.md | 5 +++++ lib/utils/background_push.dart | 18 ++++++++++-------- lib/widgets/matrix.dart | 8 +++++++- pubspec.yaml | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf591675..a38bec9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +## v0.31.2 - 2021-05-28 + +### Fixes +* Setting up push was broken + ## v0.31.0 - 2021-05-26 ### Chore diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 167bab49..c80cee66 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -54,6 +54,7 @@ class BackgroundPush { GlobalKey router; String _fcmToken; LoginState _loginState; + void Function(String errorMsg) onFcmError; L10n l10n; Store _store; Store get store => _store ??= Store(); @@ -68,7 +69,7 @@ class BackgroundPush { DateTime lastReceivedPush; - BackgroundPush._(this.client) { + BackgroundPush._(this.client, {this.onFcmError}) { onLogin ??= client.onLoginStateChanged.stream.listen(handleLoginStateChanged); onRoomSync ??= client.onSync.stream @@ -95,10 +96,12 @@ class BackgroundPush { } factory BackgroundPush(FluffyClient _client, BuildContext _context, - GlobalKey router) { + GlobalKey router, + {final void Function(String errorMsg) onFcmError}) { final instance = BackgroundPush.clientOnly(_client); instance.context = _context; instance.router = router; + instance.onFcmError = onFcmError; instance.fullInit(); return instance; } @@ -249,12 +252,10 @@ class BackgroundPush { } if (await store.getItemBool(SettingKeys.showNoGoogle, true)) { await loadLocale(); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text( - PlatformInfos.isAndroid - ? l10n.noGoogleServicesWarning - : l10n.oopsPushError, - ))); + onFcmError?.call(PlatformInfos.isAndroid + ? l10n.noGoogleServicesWarning + : l10n.oopsPushError); + if (null == await store.getItem(SettingKeys.showNoGoogle)) { await store.setItemBool(SettingKeys.showNoGoogle, false); } @@ -262,6 +263,7 @@ class BackgroundPush { } Future setupFirebase() async { + Logs().v('Setup firebase'); if (_fcmToken?.isEmpty ?? true) { try { _fcmToken = await _fcmSharedIsolate.getToken(); diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 5d3f9bac..e0d16af1 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -354,7 +354,13 @@ class MatrixState extends State with WidgetsBindingObserver { } if (PlatformInfos.isMobile) { - _backgroundPush = BackgroundPush(client, navigatorContext, widget.router); + _backgroundPush = BackgroundPush( + client, + context, + widget.router, + onFcmError: (errorMsg) => ScaffoldMessenger.of(context) + .showSnackBar(SnackBar(content: Text(errorMsg))), + ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 44c98b5e..73955152 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fluffychat description: Chat with your friends. publish_to: none -version: 0.31.1+0 +version: 0.31.2+0 environment: sdk: ">=2.6.0 <3.0.0"