0

I'm having issues presenting a UIAlertViewController. I get the following error when trying to execute the function:

2018-12-19 12:06:55.752953+0000 LoopUltimate[2545:108128] Warning: Attempt to present on whose view is not in the window hierarchy!

func enableDNDAlert(){
    //Check if DND is enabled in Firebase Remote Config
    if DNDSet.contains("no") {
        print("DND enabled")
        let alertController = UIAlertController.init(title: "Enable Do Not Disturb and return to Loop",message: "", preferredStyle: .alert)
        alertController.addAction(UIAlertAction.init(title: "Enable", style: .default, handler: { (action) in
            self.enableDND() }))
        self.present(alertController, animated: true) {}
    } else {
        print("Hidden")
    }
}
Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92

0 Answers0