Skip to content

Make NotifierManager.onUserNotification and NotifierManager.onNotificationClicked public on iOS API#131

Merged
mirzemehdi merged 2 commits intomirzemehdi:mainfrom
zsmb13:open-ios-apis
Mar 20, 2025
Merged

Make NotifierManager.onUserNotification and NotifierManager.onNotificationClicked public on iOS API#131
mirzemehdi merged 2 commits intomirzemehdi:mainfrom
zsmb13:open-ios-apis

Conversation

@zsmb13
Copy link
Contributor

@zsmb13 zsmb13 commented Mar 19, 2025

To be merged after #130

Opens two iOS-related methods, onUserNotification and onNotificationClicked to the public. This is needed if the user wants to set their own NotificationDelegate instead of the library's own implementation, which is currently the only place where these methods are called from.

Also puts the initialization code in FirebasePushNotifierImpl back into the blocking path, because if it's asynchronous, iOS system events like userNotificationCenter(.., didReceive response: UNNotificationResponse, ..) are delivered before the library sets these delegates and they'll be missed.


Overall, as NotifierManager.initialize() now sets the library's delegates instantly, and the methods called by the delegate are also accessible, it still allows the user to set their own delegate to replace what the library configures immediately after calling NotifierManager.initialize(), and it will work as expected.

@zsmb13 zsmb13 changed the title Open iOS APIs Open iOS APIs, make delegate init blocking Mar 19, 2025
zsmb13 added 2 commits March 20, 2025 10:36
…Impl

This runs the initialization logic setting delegates immediately if already called from the main thread, instead of asynchronously
@zsmb13 zsmb13 changed the title Open iOS APIs, make delegate init blocking Open iOS APIs, make delegate init non-dispatching when called from main Mar 20, 2025
Copy link
Owner

@mirzemehdi mirzemehdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! Thank you

@mirzemehdi mirzemehdi changed the title Open iOS APIs, make delegate init non-dispatching when called from main Make NotifierManager.onUserNotification and NotifierManager.onNotificationClicked public on iOS API Mar 20, 2025
@mirzemehdi
Copy link
Owner

People coming to this PR:

If you set your own notification delegate on ios side, you will need to call both on didReceiveNotificationResponse

NotifierManager.onUserNotification(notificationContent)
NotifierManager.onNotificationClicked(notificationContent)

and on willPresentNotification you will need to call NotifierManager.onUserNotification(notificationContent)


You can check NotificationDelegate implementation in the library: https://github.com/mirzemehdi/KMPNotifier/blob/b2774fcbb80d00adff9572966ffc9cd80fd67581/kmpnotifier/src/iosMain/kotlin/com/mmk/kmpnotifier/notification/IosNotifier.kt#L152C5-L156C20

@mirzemehdi mirzemehdi merged commit 790e010 into mirzemehdi:main Mar 20, 2025
4 checks passed
@zsmb13 zsmb13 deleted the open-ios-apis branch March 20, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants