Open grifas opened 6 years ago
Hi.
I would think you'd want to set the root view controller on UIApplication.shared.delegate?.window??
not UIApplication.shared.keyWindow?
which isn't necessarily your application's main window.
If that isn't helpful, a few questions:
presentationContext
setting?SwiftMessages.Config.becomeKeyWindow
property?While debugging with the displayed notification
po UIApplication.shared.keyWindow?.rootViewController
returns:
▿ Optional<UIViewController>
▿ some : <Target.HomeViewController: 0x10238c410>
po UIApplication.shared.keyWindow?.rootViewController
returns:
▿ Optional<UIViewController>
▿ some : <SwiftMessages.WindowViewController: 0x10c3005e0>
I found a trick to fix my issue:
func logout() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateInitialViewController()
if !(UIApplication.shared.keyWindow?.rootViewController is HomeViewController) {
UIApplication.shared.keyWindow?.isHidden = true
}
UIApplication.shared.keyWindow?.rootViewController = controller
UIApplication.shared.keyWindow?.makeKeyAndVisible()
}
Otherwise, I tried with UIApplication.shared.delegate?.window??
and it works fine !
Thanks. I'll need to investigate why the key window behavior changed in iOS 11.
I haven't been able to reproduce this. Try running the attached test app. Tap "Show" and then "Hide" and check the key window instance IDs printed in the console. For me they match. I'm not sure what else I can do unless you can help me reproduce.
Issue
I have a function that logout my user:
but it doesn't work when a notification is displayed:
Confirguration
Version: iOS 11 Device: iPhone 6s SDK: Swift 3 SwiftMessages Version: 4.0.0
Have you an idea ?