- Add Apple Sign-In backend (JWKS verification, account linking, session management) - Implement push notification deep linking with NotificationDeepLinkRouter - Add jailbreak detection, runtime integrity monitoring, secure enclave service - Implement OAuth social login, token refresh, and secure logout flows - Add image caching (memory/disk), optimizer, upload queue, async semaphore - Implement notification analytics, type preferences, and category setup - Expand UI test suite with UITestBase, accessibility, auth flow, performance tests - Add CI pipeline for iOS UI tests (3 device sizes) and performance benchmarks - Restructure Xcode project to manual groups with KordantWidgets target - Add SwiftLint, Swift Collections/Algorithms/GoogleSignIn dependencies - Update project.yml for XcodeGen with new targets and configurations
47 lines
1.6 KiB
Swift
47 lines
1.6 KiB
Swift
import Foundation
|
|
|
|
/// Reads and writes WidgetData from the shared App Group UserDefaults container.
|
|
/// Compiled into both the main app and widget extension targets.
|
|
final class WidgetDataManager {
|
|
static let shared = WidgetDataManager()
|
|
|
|
private let suiteName = "group.com.frenocorp.kordant"
|
|
private let dataKey = "com.frenocorp.kordant.widgetData"
|
|
|
|
private init() {}
|
|
|
|
/// Persist widget data to the shared container.
|
|
func save(_ data: WidgetData) {
|
|
guard let defaults = UserDefaults(suiteName: suiteName) else {
|
|
assertionFailure("WidgetDataManager: Unable to access App Group UserDefaults")
|
|
return
|
|
}
|
|
do {
|
|
let encoded = try JSONEncoder().encode(data)
|
|
defaults.set(encoded, forKey: dataKey)
|
|
} catch {
|
|
assertionFailure("WidgetDataManager: Failed to encode widget data: \(error)")
|
|
}
|
|
}
|
|
|
|
/// Load widget data from the shared container.
|
|
/// Returns `nil` if no data has been written yet.
|
|
func load() -> WidgetData? {
|
|
guard let defaults = UserDefaults(suiteName: suiteName),
|
|
let data = defaults.data(forKey: dataKey) else {
|
|
return nil
|
|
}
|
|
do {
|
|
return try JSONDecoder().decode(WidgetData.self, from: data)
|
|
} catch {
|
|
assertionFailure("WidgetDataManager: Failed to decode widget data: \(error)")
|
|
return nil
|
|
}
|
|
}
|
|
|
|
/// Remove all stored widget data (e.g. on logout).
|
|
func clear() {
|
|
UserDefaults(suiteName: suiteName)?.removeObject(forKey: dataKey)
|
|
}
|
|
}
|