Search code examples
swifticloudtvos

NSFileManager ubiquityIdentityToken always nil tvOS


I am working on adding iCloud KVS to store settings and scores in an iOS/tvOS app.

Everything is set up and working fine on iOS devices; However, my AppleTV always returns nil when I check for the ubiquityIdentityToken.

My function, below, is as per Apple's guidelines.

func iCloudAvailable() -> Bool {
   let token = NSFileManager.defaultManager().ubiquityIdentityToken

   if token == nil {
      return false
   }

   return true
}

One thing to note is that, if I force the function to return true, my AppleTV will sync with settings and scores stored in iCloud.

I'm failing to see what I may be missing as I can not seem to find any specific information regarding iCloud KVS on AppleTV.

EDIT

For clarification, I would like to confirm that I am actually logged in to iCloud.


Solution

  • According to this answer , I don't even need to be checking for the availability of iCloud as Apple's own iCloud fundamentals guide states that the Key Value Store should be considered to be always available.

    So, in my case, it is safe to continue my KVS usage and ignore the fact that the .ubiquityIdentityToken is nil.