Group Group Group Group Group Group Group Group Group

Push Notifications · Tap to App | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1258151-push-notifications/lessons/5

Hey there, gread video and thanks for that!
But how can we add this action to open an ViewController after tapping the Notification while the App is running in background? That seems to be very difficult and I cannot find any working solution for that…

Great Job.

thanks Thomas! it’s only for convenient testing that I show the push notification arriving with the app running. Normally, notifications arrive when the app isn’t running. I’ve just sent this notification to my phone in sleep mode (screen off) after quitting the app (dragging it out of the quick view) — tapping the notification opens the otter spot view controller in the app.

Hi audrey, thanks for your fast reply.

If I use the code like you, I get " Fatal error: Unexpectedly found nil while unwrapping an Optional value:" which is caused from the line where I force unwrapp the rootviewcontroller.
I do not know why this is happening, and in your code it works very well.

hi Thomas! Are you trying to open a view controller in your own app? Make sure you’ve given it a View Controller Title in its attributes inspector or in code, to match the withIdentifier argument.

You don’t get this error when the app is running in the foreground?