Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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);
    }
}];
like image 786
croc_hunter Avatar asked Apr 27 '15 03:04

croc_hunter


2 Answers

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

like image 175
Holmes Avatar answered Sep 26 '22 03:09

Holmes


If you're testing your app against CloudKit's Production environment, you may still have this error even if you have signed into iCloud on the simulator. In this case, running your app on a device would fix the error.

like image 43
CodeBrew Avatar answered Sep 28 '22 03:09

CodeBrew