I am new to Swift and Firebase, I implemented the FCM perfectly, I am processing the data inside each notification and display it. However, I had a problem: Instead of tapping the pop-out windows of notification, I later tapped the APP ICON and the notification wasn't got processed and no data was updated on my app page.
Can someone please tell me how to fix this? My intuition is to write something in AppDelegate, but I had already had the same process in func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any])
and application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
as the other function has. Thank you!
I later tapped the APP ICON and the notification wasn't got processed and no data was updated on my app page.
That's expected. If your app has 10 notifications received and you tapped on the app icon, how is your suppose to know which notification it needs to process?
so, no way to process notification data if tapping the home screen? any other recommendation?
You can process get all the delivered notifications through a callback for when app is opened. See here. You can query the delivered notifications all items...
Do you know where to put this function? Is it gonna be in appDelegate? I assume getDeliveredNotifications(completionHandler:) will be called every time when user tap the app ICON back, but do you know what appDelegate function would call back when this action happen?
If you wanted it to be called whenever app icon is hit then I’d say get a callback for
applicationWillEnterForeground
and then make that function call and get all the delivered notifications. But you call use that callback from anywhere and get the delivered notifications...