diff --git a/Signal/src/UIApplication+OWS.swift b/Signal/src/UIApplication+OWS.swift index b9062122f..90cfc5b24 100644 --- a/Signal/src/UIApplication+OWS.swift +++ b/Signal/src/UIApplication+OWS.swift @@ -9,8 +9,20 @@ extension UIApplication { var frontmostViewController: UIViewController? { let window = UIApplication.shared.keyWindow var viewController = window!.rootViewController - while viewController?.presentedViewController != nil { - viewController = viewController?.presentedViewController + + while true { + if let nextViewController = viewController?.presentedViewController { + viewController = nextViewController + } else if viewController is UINavigationController { + let navigationController = viewController as? UINavigationController + if let nextViewController = navigationController?.topViewController { + viewController = nextViewController + } else { + break + } + } else { + break + } } return viewController diff --git a/Signal/src/util/AppUpdateNag.m b/Signal/src/util/AppUpdateNag.m index 16e0d24f4..0dad6e976 100644 --- a/Signal/src/util/AppUpdateNag.m +++ b/Signal/src/util/AppUpdateNag.m @@ -3,6 +3,8 @@ // #import "AppUpdateNag.h" +#import "RegistrationViewController.h" +#import "Signal-Swift.h" #import #import @@ -55,6 +57,17 @@ NSString *const TSStorageManagerAppUpgradeNagDate = @"TSStorageManagerAppUpgrade - (void)showAppUpgradeNagIfNecessary { + // Only show nag if we are "at rest" in the home view or registration view without any + // alerts or dialogs showing. + UIViewController *frontmostViewController = + [UIApplication sharedApplication].frontmostViewController; + OWSAssert(frontmostViewController); + BOOL canPresent = ([frontmostViewController isKindOfClass:[SignalsViewController class]] || + [frontmostViewController isKindOfClass:[RegistrationViewController class]]); + if (!canPresent) { + return; + } + NSDate *lastNagDate = [[TSStorageManager sharedManager] dateForKey:TSStorageManagerAppUpgradeNagDate inCollection:TSStorageManagerAppUpgradeNagCollection]; const NSTimeInterval kMinute = 60.f;