mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Attempt to auto-configure push notifications to remove one tour pane
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import 'package:comunic/helpers/firebase_messaging_helper.dart';
|
||||
import 'package:comunic/helpers/independent_push_notifications_helper.dart';
|
||||
import 'package:comunic/helpers/preferences_helper.dart';
|
||||
import 'package:comunic/helpers/server_config_helper.dart';
|
||||
import 'package:comunic/models/api_request.dart';
|
||||
import 'package:comunic/utils/flutter_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Push notifications helper
|
||||
///
|
||||
@ -58,6 +60,34 @@ class PushNotificationsHelper {
|
||||
IndependentPushNotificationsHelper.disable();
|
||||
}
|
||||
|
||||
/// Configure push notifications
|
||||
static Future<void> configure(
|
||||
BuildContext context, PushNotificationsStatus newStatus) async {
|
||||
String firebaseToken = "";
|
||||
switch (newStatus) {
|
||||
case PushNotificationsStatus.DISABLED:
|
||||
break;
|
||||
|
||||
case PushNotificationsStatus.FIREBASE:
|
||||
await FirebaseMessagingHelper.preConfigure();
|
||||
firebaseToken = await FirebaseMessagingHelper.getToken();
|
||||
break;
|
||||
|
||||
case PushNotificationsStatus.INDEPENDENT:
|
||||
if (await IndependentPushNotificationsHelper.needPreConfiguration())
|
||||
await IndependentPushNotificationsHelper.preConfigure(context);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown status!");
|
||||
}
|
||||
|
||||
await PushNotificationsHelper.clearLocalStatus();
|
||||
await PushNotificationsHelper.setNewStatus(newStatus,
|
||||
firebaseToken: firebaseToken);
|
||||
await PushNotificationsHelper.refreshLocalStatus();
|
||||
}
|
||||
|
||||
/// Set new push notification status on the server
|
||||
static Future<void> setNewStatus(
|
||||
PushNotificationsStatus newStatus, {
|
||||
|
Reference in New Issue
Block a user