My app delegate has a RootViewController *viewController; and the app launches with this view.
From here on I will continue to present modal views (up to 3 levels) as the user navigates to different functions within the app.
I have setup the app to receive push notifications, and I have didReceiveRemoteNotification inside the app delegate to retrieve the payload.
Now the questions:
- When the push notification is received, how can I know which modal view the user is currently in?
- How do I close all the modal views to return to the RootViewController? Can I actually do this within the app delegate?
There’s no generic built-in way of doing this. The best solution is probably to add a property to your app delegate where you can store it.
When you present modal view controllers, do this:
You also need to make sure you lose the reference when dismissing:
Then in your app delegate, you have everything you need in order to dismiss the current modal view controller and check if there is a modal view controller present at the moment.