Swift 4 Attempt to present ViewController whose view is not in the window hierarchy

This issue happens due to your view hierarchy. You need to find out what is your Current/Topmost view controller in view hierarchy and present your alert over it. To find out topmost view controller use following code: And present your alert over topmost view controller and use main thread to present an alert because closures may have … Read more