Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:11:36+00:00 2026-05-26T08:11:36+00:00

My app delegate has a RootViewController *viewController; and the app launches with this view.

  • 0

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:

  1. When the push notification is received, how can I know which modal view the user is currently in?
  2. How do I close all the modal views to return to the RootViewController? Can I actually do this within the app delegate?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:11:36+00:00Added an answer on May 26, 2026 at 8:11 am

    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.

    @property (nonatomic, retain) UIViewController *currentModalViewController;
    

    When you present modal view controllers, do this:

    #import "MyAppDelegate.h"
    
    // ....
    MyAppDelegate *appDelegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
    appDelegate.currentModalViewController = vc;
    [self presentModalViewController:vc animated:YES];
    

    You also need to make sure you lose the reference when dismissing:

    [self dismissModalViewControllerAimated:YES];
    MyAppDelegate *appDelegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
    appDelegate.currentModalViewController = nil;
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have any tips for this scenario. My app delegate's nib has a
From the standard view-based application, I found that the generated code did this: self.window.rootViewController
Here is my code stub for my app-delegate.m -- it never gets called. -
I'm converting my App Delegate file from .m to .mm (Objective-C to Objective-C++) so
Maybe I've been looking at this for too long ;) My app has a
I am developing an app that has many view. Into my app sometimes the
So I have a viewcontroller in my iPad app. It has a UIPopoverViewController with
I have a main navigationController controlled on the app's delegate and this navigationController contains
Here is the layout of my app. ApplicationName LoginViewController.h LoginViewController.m LoginView.xib AppDelegate.h AppDelegate.m ViewController.h
I'm using the following Audio Session in my app delegate: AudioSessionInitialize(NULL, NULL, NULL, self);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.