mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Avoid potential Google Play Store ban
This commit is contained in:
		@@ -1,3 +1,6 @@
 | 
			
		||||
import 'package:comunic/ui/dialogs/alert_dialog.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/cupertino.dart';
 | 
			
		||||
import 'package:flutter/services.dart';
 | 
			
		||||
 | 
			
		||||
/// Independent push notifications helper
 | 
			
		||||
@@ -8,11 +11,19 @@ class IndependentPushNotificationsHelper {
 | 
			
		||||
  static const platform = const MethodChannel(
 | 
			
		||||
      "org.communiquons.comunic/independent-push-notifications-service");
 | 
			
		||||
 | 
			
		||||
  /// Check if a pre-configuration is required for an application
 | 
			
		||||
  static Future<bool> needPreConfiguration() async {
 | 
			
		||||
    return await platform.invokeMethod("needPreConfiguration");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// 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 {
 | 
			
		||||
  static Future<void> preConfigure(BuildContext context) async {
 | 
			
		||||
    await alert(context,
 | 
			
		||||
        tr("Battery optimization settings will appear. To make push notifications service work better, please disable battery optimization for Comunic..."));
 | 
			
		||||
 | 
			
		||||
    await platform.invokeMethod("preConfigure");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -121,7 +121,8 @@ class _PushNotificationsConfigurationRouteState
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case PushNotificationsStatus.INDEPENDENT:
 | 
			
		||||
          await IndependentPushNotificationsHelper.preConfigure();
 | 
			
		||||
          if (await IndependentPushNotificationsHelper.needPreConfiguration())
 | 
			
		||||
            await IndependentPushNotificationsHelper.preConfigure(context);
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,5 @@
 | 
			
		||||
import 'package:comunic/helpers/account_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/events_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/push_notifications_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/server_config_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/version_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/websocket_helper.dart';
 | 
			
		||||
@@ -78,8 +77,8 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      print("Check push notifications configuration...");
 | 
			
		||||
      if (await PushNotificationsHelper.getLocalStatus() ==
 | 
			
		||||
          PushNotificationsStatus.UNDEFINED)
 | 
			
		||||
      /*if (await PushNotificationsHelper.getLocalStatus() ==
 | 
			
		||||
          PushNotificationsStatus.UNDEFINED)*/// TODO : remove comment
 | 
			
		||||
        await showInitialPushNotificationsConfiguration(context);
 | 
			
		||||
 | 
			
		||||
      print("Attempting WebSocket connection...");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user