Can you see that here : https://vimeo.com/279403383
I'm trying present a passcode view. Because this app is sensitive to security.
So if app did enter background, request passcode.
In this case pretty well work.
But, specific case work oddly.
func applicationDidEnterBackground(_ application: UIApplication) {
guard let passcodeManageView = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "passcodeManageView") as? PasscodeManageViewController else { return }
passcodeManageView.state = State.loginMode
passcodeManageView.modalPresentationStyle = .overFullScreen
var rootViewController = UIApplication.shared.keyWindow?.rootViewController
while let presentController = rootViewController?.presentedViewController {
rootViewController = presentController
}
rootViewController?.present(passcodeManageView, animated: false, completion: nil)
}
So, my question is
How does passcode view cover MFMessageComposeViewController?
or How to dismiss MFMessageComposeViewController?
What is the best way???
You need to iterate the presented ViewControllers of your app and close them one by one.
func applicationDidEnterBackground(_ application: UIApplication) {
if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
var presented = rootViewController.presentedViewController
while presented != nil
{
if presented is MFMessageComposeViewController {
rootViewController.dismiss(animated: false, completion: nil)
break
} else {
presented = presented?.presentedViewController
}
}
}
guard let passcodeManageView = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "passcodeManageView") as? PasscodeManageViewController else { return }
passcodeManageView.state = State.loginMode
passcodeManageView.modalPresentationStyle = .overFullScreen
var rootViewController = UIApplication.shared.keyWindow?.rootViewController
while let presentController = rootViewController?.presentedViewController {
rootViewController = presentController
}
rootViewController?.present(passcodeManageView, animated: false, completion: nil)
}