title: "Not Authenticated" (9/1002) error while accessing cloud kit public database
body: <p>I have integrated cloudkit framework in one of my iOS app and is working fine in iOS 8 and 9 but not in iOS 10. It fails to fetch the records from public database without active iCloud account. Able to fetch the records in iOS 8 and 9 if user restricted iCloud drive for the app also but it fails in iOS 10,  getting error like </p>
  
  <blockquote>
    <p>CKError 0x170249090: "Not Authenticated" (9/1002); "No backing
    account, so not returning an auth token."</p>
  </blockquote>
  
  <p>It is not working for both development and production cloudkit environments in iOS devices.
  I have tested the app with AdHoc build pointing to production.</p>
  
  <p>Below is my code</p>
  
  <pre><code>CKQuery *query = [[CKQuery alloc] initWithRecordType:@"RecordSettings" predicate:[NSPredicate predicateWithFormat:@"TRUEPREDICATE"]];
  
  CKQueryOperation *queryOperation = [[CKQueryOperation alloc] initWithQuery:query];
  queryOperation.queuePriority = NSOperationQueuePriorityVeryHigh;
  queryOperation.recordFetchedBlock = ^(CKRecord *record) {
                if(record != nil) {
              }
  };
  queryOperation.queryCompletionBlock = ^(CKQueryCursor * __nullable cursor, NSError * __nullable operationError) {
  
                      NSLog(@"iCloud error: %@", operationError.description);
  };
  [[[CKContainer defaultContainer] publicCloudDatabase] addOperation:queryOperation];
  </code></pre>