Skip to content

Commit 24feeb3

Browse files
authored
Merge pull request #56 from mirzemehdi/ios_push_notification_fixes
Fixing Ios notification bugs
2 parents acf5e45 + f2727c7 commit 24feeb3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

kmpnotifier/src/iosMain/kotlin/com/mmk/kmpnotifier/extensions/NotifierManagerExt.ios.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public fun NotifierManager.onApplicationDidReceiveRemoteNotification(userInfo: M
2929

3030
internal fun NotifierManager.onUserNotification(notificationContent: UNNotificationContent) {
3131
val userInfo = notificationContent.userInfo
32-
if (notificationContent.isPushNotification()) NotifierManagerImpl.onPushNotification(
32+
val hasNotification = notificationContent.title != null || notificationContent.body != null
33+
if (notificationContent.isPushNotification() && hasNotification) NotifierManagerImpl.onPushNotification(
3334
title = notificationContent.title,
3435
body = notificationContent.body
3536
)

kmpnotifier/src/iosMain/kotlin/com/mmk/kmpnotifier/firebase/FirebasePushNotifierImpl.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ import kotlin.coroutines.suspendCoroutine
1717
@OptIn(ExperimentalForeignApi::class)
1818
internal class FirebasePushNotifierImpl : PushNotifier {
1919

20+
private val firebaseMessageDelegate by lazy { FirebaseMessageDelegate() }
21+
2022
init {
2123
MainScope().launch {
2224
println("FirebasePushNotifier is initialized")
25+
FIRMessaging.messaging().delegate = firebaseMessageDelegate
2326
UIApplication.sharedApplication.registerForRemoteNotifications()
24-
FIRMessaging.messaging().delegate = FirebaseMessageDelegate()
2527
}
2628

2729
}

0 commit comments

Comments
 (0)