Skip to content

Commit

Permalink
Fixing Xcode warning: [UIApplication registerForRemoteNotifications] …
Browse files Browse the repository at this point in the history
…must be used from main thread only (#41)
  • Loading branch information
mirzemehdi committed Jun 23, 2024
1 parent b903239 commit 6807e2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

allprojects {
group = "io.github.mirzemehdi"
version = "1.0.0"
version = "1.0.1"
val sonatypeUsername = gradleLocalProperties(rootDir).getProperty("sonatypeUsername")
val sonatypePassword = gradleLocalProperties(rootDir).getProperty("sonatypePassword")
val gpgKeySecret = gradleLocalProperties(rootDir).getProperty("gpgKeySecret")
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ koin = "3.5.6"
kotlinx-binary-validator = "0.13.2"
dokka = "1.9.10"
firebase-messaging = "24.0.0"
kotlinx-coroutine = "1.9.0-RC"


[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
kotlinx-coroutine = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutine" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
Expand Down
1 change: 1 addition & 0 deletions kmpnotifier/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ kotlin {
}
commonMain.dependencies {
implementation(libs.koin.core)
implementation(libs.kotlinx.coroutine)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import cocoapods.FirebaseMessaging.FIRMessagingDelegateProtocol
import com.mmk.kmpnotifier.notification.NotifierManagerImpl
import com.mmk.kmpnotifier.notification.PushNotifier
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import platform.UIKit.UIApplication
import platform.UIKit.registerForRemoteNotifications
import platform.darwin.NSObject
Expand All @@ -16,9 +18,12 @@ import kotlin.coroutines.suspendCoroutine
internal class FirebasePushNotifierImpl : PushNotifier {

init {
println("FirebasePushNotifier is initialized")
UIApplication.sharedApplication.registerForRemoteNotifications()
FIRMessaging.messaging().delegate = FirebaseMessageDelegate()
MainScope().launch {
println("FirebasePushNotifier is initialized")
UIApplication.sharedApplication.registerForRemoteNotifications()
FIRMessaging.messaging().delegate = FirebaseMessageDelegate()
}

}


Expand Down

0 comments on commit 6807e2d

Please sign in to comment.