mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Ready to pre-configure independent notifications service
This commit is contained in:
		@@ -5,12 +5,13 @@
 | 
			
		||||
// ignore_for_file: lines_longer_than_80_chars
 | 
			
		||||
 | 
			
		||||
import 'package:file_picker/src/file_picker_web.dart';
 | 
			
		||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
 | 
			
		||||
import 'package:shared_preferences_web/shared_preferences_web.dart';
 | 
			
		||||
import 'package:url_launcher_web/url_launcher_web.dart';
 | 
			
		||||
import 'package:video_player_web/video_player_web.dart';
 | 
			
		||||
import 'package:wakelock_web/wakelock_web.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
 | 
			
		||||
 | 
			
		||||
// ignore: public_member_api_docs
 | 
			
		||||
void registerPlugins(Registrar registrar) {
 | 
			
		||||
  FilePickerWeb.registerWith(registrar);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								lib/helpers/independent_push_notifications_helper.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								lib/helpers/independent_push_notifications_helper.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
import 'package:flutter/services.dart';
 | 
			
		||||
 | 
			
		||||
/// Independent push notifications helper
 | 
			
		||||
///
 | 
			
		||||
/// @author Pierre Hubert
 | 
			
		||||
 | 
			
		||||
class IndependentPushNotificationsHelper {
 | 
			
		||||
  static const platform = const MethodChannel(
 | 
			
		||||
      "org.communiquons.comunic/independent-push-notifications-service");
 | 
			
		||||
 | 
			
		||||
  /// Call this method to prepare the application for background refresh by
 | 
			
		||||
  /// requesting appropriate permissions, configuring battery optimization...
 | 
			
		||||
  ///
 | 
			
		||||
  /// Throws an Exception in case of failure
 | 
			
		||||
  static Future<void> preConfigure() async {
 | 
			
		||||
    await platform.invokeMethod("preConfigure");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import 'package:comunic/helpers/independent_push_notifications_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/push_notifications_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/server_config_helper.dart';
 | 
			
		||||
import 'package:comunic/models/config.dart';
 | 
			
		||||
@@ -15,8 +16,7 @@ import 'package:flutter/material.dart';
 | 
			
		||||
Future<void> showInitialPushNotificationsConfiguration(
 | 
			
		||||
    BuildContext context) async {
 | 
			
		||||
  // Check if no notifications service are available
 | 
			
		||||
  if (!PushNotificationsHelper.arePushNotificationsAvailable)
 | 
			
		||||
    return;
 | 
			
		||||
  if (!PushNotificationsHelper.arePushNotificationsAvailable) return;
 | 
			
		||||
 | 
			
		||||
  await Navigator.of(context).push(
 | 
			
		||||
      MaterialPageRoute(builder: (c) => PushNotificationsConfigurationRoute()));
 | 
			
		||||
@@ -118,9 +118,9 @@ class _PushNotificationsConfigurationRouteState
 | 
			
		||||
          // TODO: Handle this case.
 | 
			
		||||
          throw new Exception("Firebase not supported yet!");
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case PushNotificationsStatus.INDEPENDENT:
 | 
			
		||||
          // TODO: Handle this case.
 | 
			
		||||
          throw new Exception("Independent not supported yet!");
 | 
			
		||||
          await IndependentPushNotificationsHelper.preConfigure();
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user