title: APNS Firebase Notification failed to fetch token
body: <p><strong>For Swift3 / iOS10 see this link:</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/39729249/ios10-swift-3-and-firebase-push-notifications-fcm">ios10, Swift 3 and Firebase Push Notifications (FCM)</a></p>
  
  <p>I'm trying to use the Firebase for Notifications and I integrated it exactly as described in the docs.
  But I don't understand why is doesn't work. When I build my project I see this line: </p>
  
  <pre><code>2016-05-25 16:09:34.987: &lt;FIRInstanceID/WARNING&gt; Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
  </code></pre>
  
  <p>This my AppDelegate:</p>
  
  <pre><code> func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
      FIRApp.configure()
      FIRDatabase.database().persistenceEnabled = true
       var service: DataService = DataService()
      service.start()
      registerForPushNotifications(application)
      application.registerForRemoteNotifications()
      return true
  }
  
  func registerForPushNotifications(application: UIApplication) {
      let notificationSettings = UIUserNotificationSettings(
          forTypes: [.Badge, .Sound, .Alert], categories: nil)
      application.registerUserNotificationSettings(notificationSettings)
  }
  
  func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
      if notificationSettings.types != .None {
          application.registerForRemoteNotifications()
      }
  }
  
  func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
      let tokenChars = UnsafePointer&lt;CChar&gt;(deviceToken.bytes)
      var tokenString = ""
  
      for i in 0..&lt;deviceToken.length {
          tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
      }
  
      FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Unknown)
      print("Device Token:", tokenString)
  }
  func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -&gt; Void)  {
      // Print message ID.
      print("Message ID: \(userInfo["gcm.message_id"]!)")
  
      // Print full message.
      print("%@", userInfo)
  }
  </code></pre>