0

So my goal is to fix the didReceiveResponse method in my code and be able to print the print statement when the action is tapped on in the notification.

So I have the method in my DashboardVC file in an extension:

extension DashboardVC: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

    if response.actionIdentifier == "viewNewEvent" {
       print("Notification Response")
    }
    completionHandler()
}

}

I had it in the AppDelegate at first, but when you first download an app, I think it would make more sense to be prompted the notification authorization when you actually sign up/ log in like Snapchat for example. The actionIdentifier matches perfectly fine, not a problem with that, but when the notification gets sent out and I tap on the notification action, I get this in the console:

error image

and the print statement never prints. I pasted the some of the errors into google and looked up on it, but some of the cases were completely different then mine, the only term that made the most sense from researching was background tasks. This does get called when the app is in the background about to enter the foreground so it kinda does make sense for it being a background task. Now I have no idea where to begin on how to fix an issue like this and I'm hoping that maybe somebody ran into the same issue and could explain in depth how to either find a solution or a solid workaround. Thanks in advance.

dante
  • 105
  • 11
  • Have you set the `UNUserNotificationCenter` delegate? – jnpdx Apr 07 '21 at 05:28
  • Yes, I think it's much deeper than that though, no worries if you can't figure it out. It was one of those extra add ons for cooler UI experience that I wanted, but it's not end of the world if I can't get it set up now. @jnpdx – dante Apr 07 '21 at 16:06

0 Answers0