CloudKit Queries for logged out users - ios

So according to Apple's documentation, users not logged into iCloud are still allowed to read from public databases, but when querying a public database, I get the following error:
Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)" (connection to service named com.apple.cloudd) UserInfo=0x7c3498c0 {NSDebugDescription=connection to service named com.apple.cloudd}
Here's my code for reference:
let container = CKContainer.defaultContainer()
let database = container.publicCloudDatabase
let predicate = NSPredicate(value: true)
let episodeQuery = CKQuery(recordType: "Episode", predicate: predicate)
database.performQuery(episodeQuery, inZoneWithID: nil) {
// Record handling goes here
}
Any thoughts, tips, or advice is certainly appreciated. Thanks so much

Error 4097 is returned when your application can't talk to cloudd, the CloudKit daemon.
This could either be due to an issue with entitlements or a bug in cloudd. Check your syslog for more clues and look for crash logs from cloudd. If you have a crash log for cloudd please attach it to a new radar at bugreport.apple.com

I had a similar issue - after checking the system log as suggested by #farktronix, after filtering by cloudd I saw:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unexpected expression: NSSelfExpression'
Turns out my query predicate was incorrect - in my subscription query, I was trying to use the predicate:
NSPredicate(format: "self = %#", someCKRecord)
whereas I should have been using
NSPredicate(format: "recordID = %#", someCKRecord.recordID)

I have the similar issue if I send too many times requests to iCloud.
It happens for me when I'm trying to do CKModifyRecordsOperation and there are more than 100 recordsToSave. I tried about 3 consecutive times to do this operation. And then I got this error. Then every single CloudKit API has been denied. After few minutes later, every recovered.
2019-01-14 20:27:19.326912+1300 inkDiary[27136:5424371] [LogFacilityCK] Got a connection error for operation 95C747D64BEA5FAC: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.cloudd" UserInfo={NSDebugDescription=connection to service named com.apple.cloudd}
Optional(Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.cloudd" UserInfo={NSDebugDescription=connection to service named com.apple.cloudd})

Related

Fix "Quota exceed error" in CloudKit and view container usage

I have an app that uses CloudKit for data synchronisation.
With a larger volume of users, the data synchronisation between devices stopped working with an error:
<CKError 0x600001bbaca0: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = 6D5A9621-7F98-4813-B7FC-1AE08E0AD16B;
container ID = "iCloud.EvenyCloudKit";
partial errors: {
3587C9C7-9E2C-460B-855B-C921EC4BDA3A:(com.apple.coredata.cloudkit.zone:__defaultOwner__) =
<CKError 0x600001bbac40: "Quota Exceeded" (25/2035);
server message = "Quota exceeded"; uuid = 6D5A9621-7F98-4813-B7FC-1AE08E0AD16B;
Retry after 347.0 seconds>
}>
I deployed my CloudKit schema to production, but it didn't fix the problem.
I have about 800 active users, and only small text data are stored in CloudKit.
How can I fix this problem, and how can I see the current CloudKit Container usage?
Thanks!

Issue with AWSCognito/DynamoDB (Unauthenticated access - not supported)

I am trying to use AWSCognito and DynamoDB in an iOS app.
I have followed this document.
appearently with no problem until step 5 (Create a user pool group).
For:
Step 6: Amazon DynamoDB row-level authorization
I don't quite understand what I am supposed to do.
When running this Swift code:
dynamoDbObjectMapper.save(newMyObject!, completionHandler: {
(error: Error?) -> Void in
if let error = error {
print("Amazon DynamoDB Save Error: \(error)")
return
}
print("An item was saved.")
})
I get this error:
Amazon DynamoDB Save Error: Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain
Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Unauthenticated
access is not supported for this identity pool.}
But I do not intend to have "Unauthenticated access".
I was expecting to be asked for a username/password at some point.
I must have either done something wrong on the way or not done something I should've done.
The fact is I have no experience setting up AWSCognito/DynamoDB to work together.

GooglePlaces API "Response That We Couldn't Understand" Error

Using the standard autocomplete code with a searchbar:
placesClient.autocompleteQuery(searchBar.textField.text!, bounds: nil, filter: filter, callback: {(results, error) -> Void in
if let error = error {
print("Autocomplete error \(error)")
return
}
if let results = results {
for result in results {
print("Result \(result.attributedFullText) with placeID \(result.placeID)")
self.predictions.append(result)
}
}
self.placesTableView.reloadData()
})
Has been working for months and tonight it started reporting this error:
Autocomplete error Error Domain=com.google.places.ErrorDomain Code=-2 "The Places API server returned a response that we couldn't understand. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/support)."
UserInfo={NSLocalizedFailureReason=The Places API server returned a response that we couldn't understand. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/support)., NSUnderlyingError=0x600000444380 {Error Domain=com.google.places.server.ErrorDomain Code=-1 "(null)" UserInfo={NSUnderlyingError=0x600000444350 {Error Domain=com.google.HTTPStatus Code=404 "Not Found" UserInfo={NSLocalizedDescription=Not Found}}}}}
Anyone else experiencing this?
Looks like the service is back up. I raised a ticket with Google.
They identified the issue and are resolving it. Mentioned it could take a few hours.
See below:
https://issuetracker.google.com/issues/64280749
https://issuetracker.google.com/issues/64994023
This issue has been filed with Google, Google has identified the bug, and they are currently working on a fix. Issue tracking: https://issuetracker.google.com/issues/64280749
See: why loading places in iOS using google places api causes lookup place id query error?
thank-you: #trishcode

Google Places API Autocomplete not working bad request

I'm trying to use Google places API to get autocomplete.
I've checked everything:
API keys are activated (disabled every restriction)
I'm calling GMSServices.provideAPIKey and GMSPlacesClient.provideAPIKey
Initializing the object placesClient = GMSPlacesClient.shared()
The call I'm making is:
let filter = GMSAutocompleteFilter()
filter.type = .establishment
placesClient?.autocompleteQuery(textField.text!, bounds: nil, filter: filter) { (predictionList, error) in
if let error = error {
print("Pick Place error: \(error.localizedDescription)")
return
}
if let list = predictionList{
self.resultList = list
}
}
The error I'm getting is:
Printing description of error: Error
Domain=com.google.places.ErrorDomain Code=-3 "An internal error
occurred in the Places API library. If you believe this error
represents a bug, please file a report using the instructions on our
community and support page
(https://developers.google.com/places/support)."
UserInfo={NSLocalizedFailureReason=An internal error occurred in the
Places API library. If you believe this error represents a bug, please
file a report using the instructions on our community and support page
(https://developers.google.com/places/support).,
NSUnderlyingError=0x608000445370 {Error
Domain=com.google.places.server.ErrorDomain Code=-1 "(null)"
UserInfo={NSUnderlyingError=0x60800024f030 {Error
Domain=com.google.GTLRErrorObjectDomain Code=400 "(Bad Request)"
UserInfo={error=Bad Request, GTLRStructuredError=GMSx_GTLRErrorObject
0x60800024f9f0: {message:"Bad Request" errors:[1] code:400},
NSLocalizedFailureReason=(Bad Request)}}}}}
Has anyone else seen this problem in Xcode 8 iOS 10? Thanks
EDIT: Now it seems that some requests are working... Maybe the server is having problems?

CloudKit: "There is no operation associated with this request"

When attempting to save a CloudKit CKRecord, I get a CKError returned which gives the following description:
<CKError 0x7fd3d24e1810: "Internal Error" (1/2005); "there is no operation
associated with this request">
Any ideas what might cause this? Google does not return any results at all to this error.
This error is mentioned in the CloudKit constants reference here. Clearly this is some sort of internal issue in CK. Is the issue recurring? Are you doing anything special in this operation?

Resources