mirror of
https://github.com/yattee/yattee.git
synced 2026-02-21 10:19:46 +00:00
Fix BGTaskScheduler crash by moving registration to App.init()
Apple requires BGTaskScheduler.register() to be called during the app launch sequence before the run loop starts. Moving it from .onAppear (too late) to init() prevents the crash on TestFlight builds.
This commit is contained in:
@@ -50,6 +50,10 @@ struct YatteeApp: App {
|
|||||||
init() {
|
init() {
|
||||||
// Configure Nuke image loading pipeline
|
// Configure Nuke image loading pipeline
|
||||||
ImageLoadingService.shared.configure()
|
ImageLoadingService.shared.configure()
|
||||||
|
|
||||||
|
// Register background tasks early — Apple requires BGTaskScheduler.register()
|
||||||
|
// to be called during the app launch sequence, before the run loop starts.
|
||||||
|
appEnvironment.backgroundRefreshManager.registerBackgroundTasks()
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
@@ -253,9 +257,6 @@ struct YatteeApp: App {
|
|||||||
guard !backgroundTasksRegistered else { return }
|
guard !backgroundTasksRegistered else { return }
|
||||||
backgroundTasksRegistered = true
|
backgroundTasksRegistered = true
|
||||||
|
|
||||||
// Register background tasks
|
|
||||||
appEnvironment.backgroundRefreshManager.registerBackgroundTasks()
|
|
||||||
|
|
||||||
// If notifications are enabled, schedule the first refresh
|
// If notifications are enabled, schedule the first refresh
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if appEnvironment.settingsManager.backgroundNotificationsEnabled {
|
if appEnvironment.settingsManager.backgroundNotificationsEnabled {
|
||||||
|
|||||||
Reference in New Issue
Block a user