I know how to raise local notifications and show actions on it. When a user clicks on actions I can handle it on below method:
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse, withCompletionHandler
completionHandler: @escaping () -> Void) {
// Do something here
if response.notification.request.content.userInfo["backUp"] {
doBackUpHere()
// Do other methods
}
}
However, my situation is a little different. I need to do some functions when a notification raised before clicking on it or on it's actions(application is foreground or background). Other methods run when the user clicks on notification
func notificationRaised (notification: Notification){
// to do if notification is
if notification.userInfo["backUp"] {
doBackUpHere()
}
}
Update
Please see @Sergey answer and our comments to understand better my propose.