Search code examples
objective-ccloudkit

"Couldn't send a valid signature" error when using CloudKit


Anyone know what could be causing this error which is returned in the query block below:

<CKError 0x7f8d5ba27a10: "Internal Error" (1/4000); "Couldn't send a valid signature">

Here is my code snippet:

CKContainer *container = [CKContainer defaultContainer];
CKDatabase *publicDatabase = [container publicCloudDatabase];

//CKDatabase *publicDatabase = [[CKContainer containerWithIdentifier:container] publicCloudDatabase];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"doctorName = %@", @"Dr. Harry White"];
CKQuery *query = [[CKQuery alloc] initWithRecordType:@"WellnessTest" predicate:predicate];

[publicDatabase performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error)
{
    if (error)
    {
        // Error handling for failed fetch from public database
        NSLog(@"ERROR: %@", error.description);
    }
    else
    {
        // Display the fetched records
        NSLog(@"Results: %@", results.description);
    }
}];

Solution

  • On the iPhone/iPad simulator go to Settings > iCloud and then log in using your Apple ID.