Code Monkey home page Code Monkey logo

flutter_cloud_kit's Introduction

flutter_cloud_kit

A simple flutter plugin for interactions with Apple Cloud Kit API on iOS devices.

Currently, the following functionality is supported:

  • getAccountStatus - getting status of the user account;
  • saveRecord - saving records;
  • getRecord - getting records by key;
  • getRecordsByType - getting records by type;
  • deleteRecord - deleting record by key.

Usage

Creating an instance of the FlutterCloudKit class

FlutterCloudKit cloudKit = FlutterCloudKit(containerId: exampleContainerId);

containerId parameter is optional. When not provided, the default container will be used.

Getting account status

CloudKitAccountStatus accountStatus = await cloudKit.getAccountStatus();

Saving a record

await cloudKit.saveRecord(scope: CloudKitDatabaseScope.private, recordType: exampleRecordType, record: {'fieldName': 'fieldValue'}, recordName: 'RecordName');

Getting a record

CloudKitRecord record = await cloudKit.getRecord(scope: CloudKitDatabaseScope.private, recordName: 'RecordName');

Getting records by type

List<CloudKitRecord> records = await cloudKit.getRecordsByType(scope: CloudKitDatabaseScope.private, recordType: exampleRecordType);

Deleting a record

await cloudKit.deleteRecord(scope: CloudKitDatabaseScope.private, recordName: 'RecordName');

Setup

See Enabling CloudKit in Your App.

Basically, before you start using the plugin, you need to:

  • Add the iCloud Capability to Your Xcode Project;
  • Create a container you're going to use in Xcode;
  • Select the CloudKit checkbox;
  • Check the box next to the container name;

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:

  1. Create the first record of this type;
  2. Go to the CloudKit Console;
  3. Select your database;
  4. Go to the Indexes;
  5. Select your record type;
  6. Click Add Basic Index and create two indexes:
    • FIELD: recordName and Index Type: QUERYABLE (needed to fetch records);
    • FIELD: createdTimestamp and Index Type: SORTABLE (needed to sort them by creation time).
  7. Click Save Changes

flutter_cloud_kit's People

Contributors

f-person avatar mpoplavkov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.