Skip to content

Commit 620a269

Browse files
committed
fix: drop MainActor.assumeIsolated from BGTask registration to prevent background crash, bump build to 18
1 parent 3bdc43e commit 620a269

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

ios/VaultSync/Services/BackgroundSyncService.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,31 @@ enum BackgroundSyncService {
5353
/// Register background task handlers. Must be called before app finishes launching.
5454
/// Registration may fail in the Simulator (ESRCH) — failures are non-fatal.
5555
static func registerTasks() {
56-
appRefreshRegistered = MainActor.assumeIsolated {
57-
BGTaskScheduler.shared.register(
58-
forTaskWithIdentifier: appRefreshIdentifier,
59-
using: nil
60-
) { task in
61-
guard let refreshTask = task as? BGAppRefreshTask else { return }
62-
let wrapped = UnsafeSendable(value: refreshTask)
63-
Task { await handleAppRefresh(task: wrapped.value) }
64-
}
65-
}
56+
let refreshHandler: @Sendable (BGTask) -> Void = { task in
57+
guard let refreshTask = task as? BGAppRefreshTask else { return }
58+
let wrapped = UnsafeSendable(value: refreshTask)
59+
Task { await handleAppRefresh(task: wrapped.value) }
60+
}
61+
appRefreshRegistered = BGTaskScheduler.shared.register(
62+
forTaskWithIdentifier: appRefreshIdentifier,
63+
using: nil,
64+
launchHandler: refreshHandler
65+
)
6666

6767
if !appRefreshRegistered {
6868
logger.warning("Failed to register app refresh task — background refresh unavailable")
6969
}
7070

71-
continuedProcessingRegistered = MainActor.assumeIsolated {
72-
BGTaskScheduler.shared.register(
73-
forTaskWithIdentifier: continuedProcessingIdentifier,
74-
using: nil
75-
) { task in
76-
guard let processingTask = task as? BGContinuedProcessingTask else { return }
77-
let wrapped = UnsafeSendable(value: processingTask)
78-
Task { await handleContinuedProcessing(task: wrapped.value) }
79-
}
71+
let continuedHandler: @Sendable (BGTask) -> Void = { task in
72+
guard let processingTask = task as? BGContinuedProcessingTask else { return }
73+
let wrapped = UnsafeSendable(value: processingTask)
74+
Task { await handleContinuedProcessing(task: wrapped.value) }
8075
}
76+
continuedProcessingRegistered = BGTaskScheduler.shared.register(
77+
forTaskWithIdentifier: continuedProcessingIdentifier,
78+
using: nil,
79+
launchHandler: continuedHandler
80+
)
8181

8282
if !continuedProcessingRegistered {
8383
logger.warning("Failed to register continued processing task — continued processing unavailable (expected in Simulator)")

ios/project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ targets:
5151
path: VaultSync/Info.plist
5252
properties:
5353
CFBundleShortVersionString: "1.0.2"
54-
CFBundleVersion: "17"
54+
CFBundleVersion: "18"
5555
UILaunchScreen: {}
5656
UIApplicationSceneManifest:
5757
UIApplicationSupportsMultipleScenes: false

0 commit comments

Comments
 (0)