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:
override func viewWillAppear(animated: Bool) {
self.view.hidden = true
let defaults = NSUserDefaults.standardUserDefaults()
if defaults.stringForKey("user") != nil
{
dispatch_async(dispatch_get_main_queue(), { () -> Void in
let viewController:UIViewController = self.storyboard?.instantiateViewControllerWithIdentifier("vistaInicio") as! ViewControllerInicio
self.presentViewController(viewController, animated: true, completion: nil)
})
}else
{
self.view.hidden = false
}
}
This worked smoothly me until today when I decided to implement push notifications with updating firebase following this tutorial Setting up a Firebase Cloud Messaging Client App on iOS . The problem occurs when he killed the application and enter again gives the following error code:
2016-05-19 16:05:27.647: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(full)"
2016-05-19 16:05:27.659: <FIRMessaging/INFO> FIRMessaging library version 1.1.0
2016-05-19 16:05:27.831: <FIRMessaging/WARNING> FIRMessaging registration is not ready with auth credentials
Unable to connect with FCM. Optional(Error Domain=com.google.fcm Code=501 "(null)")