Correct way to cast to and from push notification dictionary
<p>I want to cast userInfo["aps"] to a dictionary in <code>application: UIApplication, didReceiveRemoteNotification</code>. The current code I have is:</p>

<pre><code>HTTPManager.sharedInstance.pushPayload = userInfo["aps"] as! Dictionary&lt;String, AnyObject&gt;.
</code></pre>

<p>The pushPayload is defined as: <code>var pushPayload: AnyObject?</code></p>

<p>Now I try to unwrap this payload with:</p>

<pre><code>if let message = HTTPManager.sharedInstance.pushPayload?["alert"] as? String {
            print("WE HAVE A PAYLOAD AND THE MESSAGE IS: \(message)")

        } else {
            print("Nothing in the payload")
        }
</code></pre>

<p>I always get nil when I try to unwrap it, even though the payload does contain objects (I am checking using a print statement). What am I doing wrong here?</p>