From 59a9917225dd64cdc77bfcd3b280054728b26cd1 Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Wed, 01 Apr 2026 18:14:33 +0200
Subject: [PATCH] fix: L1 privacy manifest, L2 privacy policy, M3-M5 code quality, version/icon confirmed

---
 lib/services/message_store.dart |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/lib/services/message_store.dart b/lib/services/message_store.dart
index aa51fc8..faa45c4 100644
--- a/lib/services/message_store.dart
+++ b/lib/services/message_store.dart
@@ -2,6 +2,7 @@
 import 'dart:convert';
 import 'dart:io';
 
+import 'package:flutter/services.dart';
 import 'package:path_provider/path_provider.dart';
 
 import '../models/message.dart';
@@ -14,14 +15,32 @@
   static Timer? _debounceTimer;
   static final Map<String, List<Message>> _pendingSaves = {};
 
+  static const _backupChannel =
+      MethodChannel('com.mnsoft.pailot/backup');
+
   /// Initialize the base directory for message storage.
+  /// On iOS, the directory is excluded from iCloud / iTunes backup so that
+  /// large base64 image attachments do not bloat the user's cloud storage.
+  /// Messages can be re-fetched from the server if needed.
   static Future<Directory> _getBaseDir() async {
     if (_baseDir != null) return _baseDir!;
     final appDir = await getApplicationDocumentsDirectory();
     _baseDir = Directory('${appDir.path}/messages');
-    if (!await _baseDir!.exists()) {
+    final created = !await _baseDir!.exists();
+    if (created) {
       await _baseDir!.create(recursive: true);
     }
+    // Exclude from iCloud / iTunes backup (best-effort, iOS only).
+    if (Platform.isIOS) {
+      try {
+        await _backupChannel.invokeMethod<void>(
+          'excludeFromBackup',
+          _baseDir!.path,
+        );
+      } catch (_) {
+        // Non-fatal: if the channel call fails, backup exclusion is skipped.
+      }
+    }
     return _baseDir!;
   }
 

--
Gitblit v1.3.1