Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification Click not working when iOS app is closed #31

Closed
ivancaas opened this issue May 24, 2024 · 3 comments
Closed

Notification Click not working when iOS app is closed #31

ivancaas opened this issue May 24, 2024 · 3 comments

Comments

@ivancaas
Copy link

I might be wrong as I'm not an expert in iOS myself. But when I click the notification with the app in Background/Opened it gets to onNotificationClicked, but when the app is closed and I tap, the app opens but nothing happens as it's not calling that function somehow

@mirzemehdi
Copy link
Owner

@ivancaas did you do these steps in ios as it is shown in ReadMe?

iOS

Call NotifierManager.onApplicationDidReceiveRemoteNotification(userInfo: userInfo) on application's didReceiveRemoteNotification method.

 func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) async -> UIBackgroundFetchResult {
      NotifierManager.shared.onApplicationDidReceiveRemoteNotification(userInfo: userInfo)
      return UIBackgroundFetchResult.newData
 }

Detecting notification click and get payload data

Make sure you follow previous step for getting payload data properly.

NotifierManager.addListener(object : NotifierManager.Listener {
    override fun onNotificationClicked(data: PayloadData) {
        super.onNotificationClicked(data)
        println("Notification clicked, Notification payloadData: $data")
    }
}) 

@tamimattafi
Copy link

tamimattafi commented Jun 6, 2024

@mirzemehdi @ivancaas In order to handle start arguments, you need to read user Info from didFinishLaunchingWithOptions. That's because didReceiveRemoteNotification will not be called when the app is in the background.
#24 (comment)

@ivancaas
Copy link
Author

ivancaas commented Jun 6, 2024

@mirzemehdi was right about something missing, apparently I forgot to add the "NotifierManager.shared.initialize" line in the iOS App?... too many hours coding, the rest was OK, after adding it everything works as expected.

Thanks both for your help!

@ivancaas ivancaas closed this as completed Jun 6, 2024
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

No branches or pull requests

3 participants