diff --git a/Signal/src/util/OWSScreenLockUI.m b/Signal/src/util/OWSScreenLockUI.m index 16205ba6e..a1f2ecb21 100644 --- a/Signal/src/util/OWSScreenLockUI.m +++ b/Signal/src/util/OWSScreenLockUI.m @@ -393,7 +393,8 @@ const UIWindowLevel UIWindowLevel_Background = -1.f; buttonAction:^(UIAlertAction *action) { // After the alert, re-show the unlock UI. [self ensureUI]; - }]; + } + fromViewController:self.screenBlockingViewController]; } // 'Screen Blocking' window obscures the app screen: diff --git a/SignalMessaging/views/OWSAlerts.swift b/SignalMessaging/views/OWSAlerts.swift index 105c59758..344bff32f 100644 --- a/SignalMessaging/views/OWSAlerts.swift +++ b/SignalMessaging/views/OWSAlerts.swift @@ -34,11 +34,20 @@ import Foundation @objc public class func showAlert(title: String?, message: String? = nil, buttonTitle: String? = nil, buttonAction: ((UIAlertAction) -> Void)? = nil) { + guard let fromViewController = CurrentAppContext().frontmostViewController() else { + return + } + showAlert(title: title, message: message, buttonTitle: buttonTitle, buttonAction: buttonAction, + fromViewController: fromViewController) + } + + @objc + public class func showAlert(title: String?, message: String? = nil, buttonTitle: String? = nil, buttonAction: ((UIAlertAction) -> Void)? = nil, fromViewController: UIViewController?) { let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "") let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: buttonAction)) - CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil) + fromViewController?.present(alert, animated: true, completion: nil) } @objc