1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Create a service

This commit is contained in:
2021-04-14 18:03:27 +02:00
parent 0af31bc3a0
commit bf53babf53
8 changed files with 206 additions and 12 deletions

View File

@ -26,4 +26,14 @@ class IndependentPushNotificationsHelper {
await platform.invokeMethod("preConfigure");
}
/// Configure independent push notification services with a pull URL
static Future<void> configure(String wsURL) async {
await platform.invokeMethod("configure", wsURL);
}
/// Disable independent push notifications service
static Future<void> disable() async {
await platform.invokeMethod("disable");
}
}

View File

@ -1,3 +1,4 @@
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';
@ -39,7 +40,9 @@ class PushNotificationsHelper {
if (status == null) status = PushNotificationsStatus.UNDEFINED;
if (status == PushNotificationsStatus.INDEPENDENT) {
// TODO : Invoke plugin to apply new WebSocket URL
// Invoke plugin to apply new WebSocket URL
await IndependentPushNotificationsHelper.configure(
response["independent_push_url"]);
}
await (await PreferencesHelper.getInstance()).setString(
@ -51,7 +54,8 @@ class PushNotificationsHelper {
await (await PreferencesHelper.getInstance())
.removeKey(PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS);
// TODO : stop local refresh notification refresh
// Stop local refresh notification refresh
IndependentPushNotificationsHelper.disable();
}
/// Set new push notification status on the server