Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudKit public database reading without iCloud login

In the documents it says that CloudKit public databases will be available to read even if the user did not login with a proper iCloud account. However, I cannot fetch anything from my cloud database if i didn't connect my iOS simulator or device to iCloud. When i activate my iCloud account I am able to fetch data from my public database. If anyone who has an answer or same problem with me could answer that would be great. Thanks.

CKDatabase *publicDatabase = [[CKContainer containerWithIdentifier:@"mycontainer"] publicCloudDatabase];
CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"idofmyrecord"] ;

[publicDatabase fetchRecordWithID:recordID completionHandler:^(CKRecord *fetchedRecord, NSError *error) {
    if(!error){
        NSLog(@"****Success***** %@",fetchedRecord[@"field1"]);

    }else{
        NSLog(@"****Failed***** %@",fetchedRecord[@"field2"]);

    }
}];
like image 715
Ersin Sezgin Avatar asked Sep 25 '14 12:09

Ersin Sezgin


People also ask

Do CloudKit apps sync with iCloud users?

Sync user data between multiple apps from the same developer If you have a suite of apps, they can all share the same CloudKit container so users can have access to their data for all of your apps on every device they have associated with their iCloud account.

Does Apple use CloudKit?

Since CloudKit is deeply tied to Apple's operating systems and devices, it's not suitable for applications that require a broader range of device support, such as Android or Windows clients.

Is CloudKit free?

Cost. Although the running cost of servers is a big deal for developers. But in case of CloudKit you don't have to be worried about paying large expenses at all. As it offers a reasonable storage amount completely free.

What is http Apple CloudKit com?

CloudKit is a framework that lets app developers store key-value data, structured data, and assets in iCloud. Access to CloudKit is controlled using app entitlements. CloudKit supports both public and private databases.


1 Answers

The public database is only readable with no login in the production environment, not in the development environment.

Apple's documentation says:

In development, when you run your app through Xcode on a simulator or a device, you need to enter iCloud credentials to read records in the public database. In production, the default permissions allow non-authenticated users to read records in the public database but do not allow them to write records.

See CloudKit Quick Start.

like image 187
Yann Bodson Avatar answered Oct 06 '22 01:10

Yann Bodson