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);
}
}];
On the iPhone/iPad simulator go to Settings > iCloud and then log in using your Apple ID.
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.
Related
I'ved got a strange error for AVCaptureDevice that only happens on iPhone6. I'ved tried it on iPhone6S and iPad and it works fine. The error is: Domain=AVFoundationErrorDomain Code=-11814
Here is the error print output:
Unable to obtain video device input, error: Error Domain=AVFoundationErrorDomain Code=-11814 "Cannot Record" UserInfo={NSLocalizedDescription=Cannot Record, NSLocalizedRecoverySuggestion=Try recording again.}
Here is the code snippet. There is no return in videoDevices, so it skips that. Usually its able to obtain that but not for iPhone6.
//get the front camera
NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in videoDevices)
{
if (device.position == AVCaptureDevicePositionFront) {
_videoDevice = device;
break;
}
}
// obtain device input
NSError *error = nil;
AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:_videoDevice error:&error];
if (!videoDeviceInput)
{
NSLog(#"%#", [NSString stringWithFormat:#"Unable to obtain video device input, error: %#", error]); <--- the print out message is from here.
return;
}
How can I solve this, it only happens on iPhone6. Its been updated to latest version 12.4.6.
When I execute this code:
CKDatabase *publicDatabase = [[CKContainer defaultContainer] publicCloudDatabase];
CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName: #"95263874-C860-4190-A2BB-08B3E652B7AA"];
NSPredicate *predicate = [NSPredicate predicateWithFormat: #"%K == %#", #"recordID", [[CKReference alloc] initWithRecordID: recordID action: CKReferenceActionNone]];
CKQuery *query = [[CKQuery alloc] initWithRecordType: #"Case" predicate: predicate];
[publicDatabase performQuery: query inZoneWithID: nil completionHandler: ^(NSArray *results, NSError *error) {
if (error) {
NSLog(#"Error = %#", error);
} else {
NSLog(#"Success");
}
}];
I get this error:
<CKError 0x618000042670: "Server Rejected Request" (15/2000); server message = "Internal server error"; uuid = 122AB9AA-6949-442D-B9D7-736A5B7D2EE5; container ID = "iCloud.net.xxxxxxx">
However, if I change the predicate to this:
NSPredicate *predicate = [NSPredicate predicateWithFormat: #"PatientName = %# ", #"Doe, John"];
The retrieve works correctly. I have verified that John Doe has record name that I am searching for. I have also tried toggling the iCloud "Capability" in the project settings. I have spent hours and hours on this issue and have tried many variations. Nothing works!
Make sure that you've marked Record ID as queryable for this record type in the CloudKit Dashboard.
Select your record type and click on "Metadata Indexes". Check the Query checkbox next to the Record ID field and this error should go away.
Aside from that, rmaddy's answer is right- if you're just trying to fetch a record by its identifier you should use CKFetchRecordsOperation instead of a query.
I Have used EKSpanThisEvent so when I try to remove single event from device calendar it crashes, Instead of that if I use EKSpanFutureEvents it does not get crash but it will remove all future events with same eventIdentifier even though we try to remove single event from device calendar
Crash detail is as Follow
Assertion failure in -[EKEvent _deleteThisOccurrence]
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'I screwed up somewhere in date calculation'
I tried all solutions from all sources but unfortunately none was useful, Any Help will be Highly Appreciated
CODE
if([identifier length] > 0)
{
__block EKEventStore* store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (!granted) return;
NSDate *eventdate = [commonUnit getSystemTimeZoneDateFromDate:strdate fromFormate:#"yyyy-MM-dd"];
NSPredicate *predicate = [store predicateForEventsWithStartDate:eventdate
endDate:[eventdate dateByAddingTimeInterval:86400]
calendars:nil];
NSMutableArray *events = [NSMutableArray arrayWithArray:[store eventsMatchingPredicate:predicate]];
NSPredicate *predicateidentifier = [NSPredicate predicateWithFormat:[NSString stringWithFormat:#"eventIdentifier = '%#'",identifier]];
[events filterUsingPredicate:predicateidentifier];
if (events.count > 0) {
NSError* error = nil;
[store removeEvent:events[0] span:status?EKSpanFutureEvents:EKSpanThisEvent commit:YES error:&error];
if(error == nil)
{
callbackBlock(TRUE);
}
else
{
callbackBlock(FALSE);
}
}
}];
}
I am upgrading to the facebook 3.0 sdk for ios. Things went well, until I tried to open an existing session after relaunching the application. I am trying to access the list of friends for the facebook user.
if ([[FBSession activeSession] isOpen]) {
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//do something here
}];
}else{
[[self session] openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if ([self isValid]) {
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//log this error we always get
NSLog(#"%#",error);
//do something else
}];
}
}];
}
However I get this error:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1d92ff40 {com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
I've found that if I use the FBSession reauthorize method it allows me to complete the request without error, but it also means I must show UI or switch apps every time we relaunch the application which is unacceptable. Any suggestions on what I should be doing differently?
I was not setting the session on the request after logging in. Simple mistake.
[[self session] openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if ([self isValid]) {
//I should have been doing this
request.session = [FBSession activeSession];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//log this error we always get
NSLog(#"%#",error);
//do something else
}];
}
}];
I have the following code:
BOOL success;
QTCaptureSession *session = [[QTCaptureSession alloc] init];
QTCaptureDevice *device = [QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo];
success = [device open: &e];
if ( !success )
{
NSLog(#"error opening input device: %#", e);
return;
}
QTCaptureDeviceInput *input = [QTCaptureDeviceInput deviceInputWithDevice: device];
success = [session addInput: input error: &e];
if ( !success )
{
NSLog(#"error adding input device to session: %#", e);
return;
}
QTCaptureDecompressedVideoOutput *output = [[QTCaptureDecompressedVideoOutput alloc] init];
[output setDelegate: self];
success = [session addOutput: output error: &e];
if ( !success )
{
NSLog(#"error adding output device to session: %#", e);
return;
}
[session startRunning];
this is located in a bundle loaded during runtime and is part of a method that is the selector of a NSThread (aka. it runs in in a background thread and not the main thread).
My problem is, that the call to #addInput:error: never returns. What am I missing here?
The problem was, that the main thread of the application was not using the Run Loop normally provided by NSApplicationMain() in Cocoa applications. Instead I was handling events within my own while loop.
The solution was calling:
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, YES);
This thread on Apple's QuickTime mailing list for a more detailed explanation of the problem.