title: Cloud messaging handing terminate app
body: <p>I have an application that stores the user's session in NSUserDefaults. When the application is forced to close, in the initial verify whether the data controller user session there, in case if there sent it to the start window as follows:</p>
  
  <pre><code>override func viewWillAppear(animated: Bool) {
  
      self.view.hidden = true
  
      let defaults = NSUserDefaults.standardUserDefaults()
      if   defaults.stringForKey("user") != nil
      {
  
          dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in
              let viewController:UIViewController = self.storyboard?.instantiateViewControllerWithIdentifier("vistaInicio") as! ViewControllerInicio
              self.presentViewController(viewController, animated: true, completion: nil)
          })
  
  
      }else
      {
      self.view.hidden = false
  
      }
  
  }
  </code></pre>
  
  <p>This worked smoothly me until today when I decided to implement push notifications with updating firebase following this tutorial <a href="https://firebase.google.com/docs/cloud-messaging/ios/client" rel="noreferrer">
  Setting up a Firebase Cloud Messaging Client App on iOS</a> . The problem occurs when he killed the application and enter again gives the following error code:</p>
  
  <pre><code> 2016-05-19 16:05:27.647: &lt;FIRInstanceID/WARNING&gt; Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(full)"
   2016-05-19 16:05:27.659: &lt;FIRMessaging/INFO&gt; FIRMessaging library version 1.1.0
   2016-05-19 16:05:27.831: &lt;FIRMessaging/WARNING&gt; FIRMessaging registration is not ready with auth credentials
  Unable to connect with FCM. Optional(Error Domain=com.google.fcm Code=501 "(null)")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/31Kfq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/31Kfq.png" alt="Screenshot"></a></p>