I'm trying to present a `UIAlertController` from the AppDelegate in my iOS app.
Below is the alert and the present method.

```
UIAlertController *alert = [UIAlertController alertControllerWithTitle:cTitle message:cMessage preferredStyle:UIAlertControllerStyleAlert];

//Configure alert and actions

[self.window.rootViewController presentViewController:alert animated:TRUE completion:nil];

```

However, when I try to present the alert, it doesn't appear and I get the following alert in the console.

```
Warning: Attempt to present <UIAlertController: 0x145f5d60> on <UINavigationController: 0x146590f0> whose view is not in the window hierarchy!

```

What is causing the error and how do I fix it?