fix(ios): resolve build errors and add missing configureNativeFetcher method

Fixed Swift compilation errors preventing iOS build:
- Added explicit self capture [self] in closures in DailyNotificationReactivationManager
- Removed invalid BGTaskScheduler.shared.registeredTaskIdentifiers API call
- Fixed initialization order in DailyNotificationModel (verifyEntities after container init)

Added missing configureNativeFetcher method to iOS plugin:
- Implemented method matching Android functionality
- Stores configuration in UserDefaults for persistence
- Registered method in pluginMethods array
- Supports both jwtToken and jwtSecret parameters for compatibility

This resolves the runtime error "configureNativeFetcher is not a function"
that was preventing the test app from configuring the plugin.
This commit is contained in:
Jose Olarte III
2025-12-11 16:44:18 +08:00
parent 332dfbad75
commit 1bfd87a0e4
10 changed files with 292 additions and 79 deletions
@@ -142,57 +142,57 @@ class DailyNotificationReactivationManager {
Task {
let startTime = Date()
do {
try await withTimeout(seconds: Self.RECOVERY_TIMEOUT_SECONDS) {
try await withTimeout(seconds: Self.RECOVERY_TIMEOUT_SECONDS) { [self] in
NSLog("\(Self.TAG): Starting app launch recovery")
// Phase 3: Check for boot scenario first
let isBoot = detectBootScenario()
let isBoot = self.detectBootScenario()
if isBoot {
NSLog("\(Self.TAG): Boot scenario detected - performing boot recovery")
let bootStartTime = Date()
let result = try await performBootRecovery()
let result = try await self.performBootRecovery()
let bootEndTime = Date()
NSLog("\(Self.TAG): Boot recovery completed: missed=\(result.missedCount), rescheduled=\(result.rescheduledCount), verified=\(result.verifiedCount), errors=\(result.errors)")
// Record in history
try await recordRecoveryHistory(result, scenario: .boot, startTime: bootStartTime, endTime: bootEndTime)
try await self.recordRecoveryHistory(result, scenario: .boot, startTime: bootStartTime, endTime: bootEndTime)
// Update last launch time after boot recovery
updateLastLaunchTime()
self.updateLastLaunchTime()
return
}
// Step 1: Detect scenario
let scenario = try await detectScenario()
let scenario = try await self.detectScenario()
NSLog("\(Self.TAG): Detected scenario: \(scenario.rawValue)")
// Step 2: Handle based on scenario
switch scenario {
case .none:
NSLog("\(Self.TAG): No recovery needed (first launch or no notifications)")
updateLastLaunchTime()
self.updateLastLaunchTime()
return
case .warmStart:
NSLog("\(Self.TAG): Warm start detected - no recovery needed")
updateLastLaunchTime()
self.updateLastLaunchTime()
return
case .coldStart:
NSLog("\(Self.TAG): Cold start scenario - performing recovery")
let coldStartTime = Date()
let result = try await performColdStartRecovery()
let result = try await self.performColdStartRecovery()
let coldEndTime = Date()
NSLog("\(Self.TAG): Cold start recovery completed: missed=\(result.missedCount), rescheduled=\(result.rescheduledCount), verified=\(result.verifiedCount), errors=\(result.errors)")
// Record in history
try await recordRecoveryHistory(result, scenario: .coldStart, startTime: coldStartTime, endTime: coldEndTime)
updateLastLaunchTime()
try await self.recordRecoveryHistory(result, scenario: .coldStart, startTime: coldStartTime, endTime: coldEndTime)
self.updateLastLaunchTime()
case .termination:
// Phase 2: Termination recovery
NSLog("\(Self.TAG): Termination scenario detected - performing full recovery")
let termStartTime = Date()
let result = try await handleTerminationRecovery()
let result = try await self.handleTerminationRecovery()
let termEndTime = Date()
NSLog("\(Self.TAG): Termination recovery completed: missed=\(result.missedCount), rescheduled=\(result.rescheduledCount), verified=\(result.verifiedCount), errors=\(result.errors)")
// Record in history
try await recordRecoveryHistory(result, scenario: .termination, startTime: termStartTime, endTime: termEndTime)
updateLastLaunchTime()
try await self.recordRecoveryHistory(result, scenario: .termination, startTime: termStartTime, endTime: termEndTime)
self.updateLastLaunchTime()
case .boot:
// Should be handled by initial boot detection
break
@@ -854,15 +854,17 @@ class DailyNotificationReactivationManager {
]
}
let registeredIdentifiers = BGTaskScheduler.shared.registeredTaskIdentifiers
let fetchTaskRegistered = registeredIdentifiers.contains("com.timesafari.dailynotification.fetch")
let notifyTaskRegistered = registeredIdentifiers.contains("com.timesafari.dailynotification.notify")
// Note: BGTaskScheduler doesn't provide a way to query registered task identifiers
// We can only verify by attempting to schedule or by tracking registration ourselves
// For now, we'll return that registration status cannot be verified programmatically
let fetchTaskIdentifier = "com.timesafari.dailynotification.fetch"
let notifyTaskIdentifier = "com.timesafari.dailynotification.notify"
return [
"available": true,
"fetchTaskRegistered": fetchTaskRegistered,
"notifyTaskRegistered": notifyTaskRegistered,
"registeredIdentifiers": Array(registeredIdentifiers.map { $0.rawValue })
"fetchTaskRegistered": true, // Assumed registered if this method is called
"notifyTaskRegistered": true, // Assumed registered if this method is called
"message": "Registration status cannot be verified programmatically. Tasks should be registered in AppDelegate."
]
}