Hi I'm working in a chat app, when a push notification arrives I've configure some actions like "mark as read" or "Reply" within the notification. Everything works if the app is on the foreground or running in the background. However when the app is closed/killed, the notification arrives but the actions are not being triggered. What's the best approach for this situation ? Thank you
1
votes
1 Answers
0
votes
Whenever you apps awakes from killed/closed/not open state. The didReceiveNotification will not be called instead didFinishLaunching will be called. So you have to check if there is data of notification or not when the didFinishLaunching is called. You can check like this.
If (launchOptions?[.remoteNotification] as? [AnyHashable : Any]) != nil {
.... Do your code for notification handling
}
Hope this helps.