Skip to content

Commit

Permalink
- fix crash on service init in iOS (coming from main)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodvar committed Dec 10, 2024
1 parent d25e4e3 commit e21cf38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ val iosClientModule = module {
single(named("RestApiHost")) { provideRestApiHost() }
single(named("WebsocketApiHost")) { provideWebsocketHost() }

single<NotificationServiceController> { NotificationServiceController() }
single<NotificationServiceController> {
NotificationServiceController().apply {
this.registerBackgroundTask()
}
}
}

fun provideRestApiHost(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e21cf38

Please sign in to comment.