A simple flutter plugin for interactions with Apple Cloud Kit API on iOS devices.
Currently, the following functionality is supported:
FlutterCloudKit cloudKit = FlutterCloudKit(containerId: exampleContainerId);
containerId
parameter is optional. When not provided, the default container will be used.
CloudKitAccountStatus accountStatus = await cloudKit.getAccountStatus();
await cloudKit.saveRecord(scope: CloudKitDatabaseScope.private, recordType: exampleRecordType, record: {'fieldName': 'fieldValue'}, recordName: 'RecordName');
CloudKitRecord record = await cloudKit.getRecord(scope: CloudKitDatabaseScope.private, recordName: 'RecordName');
List<CloudKitRecord> records = await cloudKit.getRecordsByType(scope: CloudKitDatabaseScope.private, recordType: exampleRecordType);
await cloudKit.deleteRecord(scope: CloudKitDatabaseScope.private, recordName: 'RecordName');
See Enabling CloudKit in Your App.
Basically, before you start using the plugin, you need to:
Also, in order to be able to retrieve records by type, you will need to add some indexes to the CloudKit database.
See Enable Querying for Your Record Type.
For every new record type you'll need to do the following:
FIELD
: recordName
and Index Type
: QUERYABLE
(needed to fetch records);FIELD
: createdTimestamp
and Index Type
: SORTABLE
(needed to sort them by creation time).