From e21cf38daf670d833b84da4e3a027a122ae9a88a Mon Sep 17 00:00:00 2001 From: Rodrigo Varela Date: Tue, 10 Dec 2024 21:19:08 +1100 Subject: [PATCH] - fix crash on service init in iOS (coming from main) --- .../network/bisq/mobile/domain/di/ClientModule.ios.kt | 6 +++++- .../service/controller/NotificationServiceController.ios.kt | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/di/ClientModule.ios.kt b/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/di/ClientModule.ios.kt index 9152c34f..efee0183 100644 --- a/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/di/ClientModule.ios.kt +++ b/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/di/ClientModule.ios.kt @@ -8,7 +8,11 @@ val iosClientModule = module { single(named("RestApiHost")) { provideRestApiHost() } single(named("WebsocketApiHost")) { provideWebsocketHost() } - single { NotificationServiceController() } + single { + NotificationServiceController().apply { + this.registerBackgroundTask() + } + } } fun provideRestApiHost(): String { diff --git a/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/service/controller/NotificationServiceController.ios.kt b/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/service/controller/NotificationServiceController.ios.kt index d8eddada..e3afb847 100644 --- a/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/service/controller/NotificationServiceController.ios.kt +++ b/shared/domain/src/iosMain/kotlin/network/bisq/mobile/domain/service/controller/NotificationServiceController.ios.kt @@ -149,7 +149,8 @@ actual class NotificationServiceController: ServiceController, Logging { } - private fun registerBackgroundTask() { + // in iOS this needs to be done on app init or it will throw exception + fun registerBackgroundTask() { if (isBackgroundTaskRegistered) { logDebug("Background task is already registered.") return