iOS check in widget

This commit is contained in:
2026-01-03 18:50:54 +08:00
parent 35a9c9ff4b
commit 978b7b32fd
18 changed files with 1142 additions and 54 deletions

View File

@@ -10,26 +10,32 @@ import Foundation
private let flutterKeyPrefix = "flutter."
private let flutterKeysToSync: [String] = [
"dyn_user_tk"
"dyn_user_tk",
"app_server_url"
]
func syncDefaultsToGroup() {
print("[iOS] syncDefaultsToGroup() called")
let standard = UserDefaults.standard
let shared = UserDefaults(suiteName: "dev.solsynth.solian")
let shared = UserDefaults(suiteName: "group.solsynth.solian")
guard let shared else {
print("[iOS] App Group UserDefaults not available")
return
}
for key in flutterKeysToSync {
guard key.hasPrefix(flutterKeyPrefix) else { continue }
if let value = standard.object(forKey: key) {
print("[iOS] Syncing key to App Group: \(key)")
shared.set(value, forKey: key)
let prefixedKey = key.starts(with: flutterKeyPrefix) ? key : flutterKeyPrefix + key
if let value = standard.object(forKey: prefixedKey) {
print("[iOS] Syncing key to App Group: \(prefixedKey)")
shared.set(value, forKey: prefixedKey)
} else {
print("[iOS] Key \(prefixedKey) was not found in the app data, skipping...")
}
}
shared.synchronize()
print("[iOS] Sync completed")
}