fix: Push error message

This commit is contained in:
Christian Pauly 2022-11-04 13:49:23 +01:00
parent ee2d30bebe
commit f3a002d1a3
4 changed files with 28 additions and 25 deletions

View File

@ -2950,5 +2950,6 @@
"number": {}
}
},
"hideUnimportantStateEvents": "Hide unimportant state events"
"hideUnimportantStateEvents": "Hide unimportant state events",
"doNotShowAgain": "Do not show again"
}

View File

@ -23,7 +23,7 @@ abstract class AppConfig {
'https://gitlab.com/famedly/fluffychat/-/blob/main/PRIVACY.md';
static String get privacyUrl => _privacyUrl;
static const String enablePushTutorial =
'https://www.reddit.com/r/fluffychat/comments/qn6liu/enable_push_notifications_without_google_services/';
'https://gitlab.com/famedly/fluffychat/-/wikis/Push-Notifications-without-Google-Services';
static const String appId = 'im.fluffychat.FluffyChat';
static const String appOpenUrlScheme = 'im.fluffychat';
static String _webBaseUrl = 'https://fluffychat.im/web';

View File

@ -258,8 +258,11 @@ class BackgroundPush {
if (context == null) {
return;
}
if (await store.getItemBool(SettingKeys.showNoGoogle, true)) {
await loadLocale();
if (await store.getItemBool(SettingKeys.showNoGoogle, true) != true) {
return;
}
await loadLocale();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (PlatformInfos.isAndroid) {
onFcmError?.call(
l10n!.noGoogleServicesWarning,
@ -267,13 +270,10 @@ class BackgroundPush {
AppConfig.enablePushTutorial,
),
);
return;
}
onFcmError?.call(l10n!.oopsPushError);
if (null == await store.getItem(SettingKeys.showNoGoogle)) {
await store.setItemBool(SettingKeys.showNoGoogle, false);
}
}
});
}
Future<void> setupFirebase() async {

View File

@ -5,6 +5,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:collection/collection.dart';
import 'package:desktop_notifications/desktop_notifications.dart';
@ -400,22 +401,23 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
client,
context,
widget.router,
onFcmError: (errorMsg, {Uri? link}) => Timer(
const Duration(seconds: 1),
() {
final banner = SnackBar(
content: Text(errorMsg),
duration: const Duration(seconds: 30),
action: link == null
? null
: SnackBarAction(
label: L10n.of(navigatorContext)!.link,
onPressed: () => launch(link.toString()),
),
);
ScaffoldMessenger.of(navigatorContext).showSnackBar(banner);
},
),
onFcmError: (errorMsg, {Uri? link}) async {
final result = await showOkCancelAlertDialog(
barrierDismissible: true,
context: context,
title: L10n.of(context)!.oopsSomethingWentWrong,
message: errorMsg,
okLabel:
link == null ? L10n.of(context)!.ok : L10n.of(context)!.help,
cancelLabel: L10n.of(context)!.doNotShowAgain,
);
if (result == OkCancelResult.ok && link != null) {
launch(link.toString());
}
if (result == OkCancelResult.cancel) {
await store.setItemBool(SettingKeys.showNoGoogle, true);
}
},
);
}