Giter Site home page Giter Site logo

canvaskit's Introduction

CanvasKit by Instructure iOS


CanvasKit is a Work in Progress—the architecture is still prone to change and not all off the API endpoints are implemented.


CanvasKit is a library that will help you integrate your own third party app with Canvas by Instructure.

CanvasKit is built on the Canvas API. CanvasKit is designed to allow for great flexibility while providing an easy to use interface. You can use CanvasKit to build apps for open source versions of Canvas as well as instances hosted by Instructure.

How To Get Started

Installation with CocoaPods


NOTE: Canvas Kit is not yet a cocoapod but will be soon


CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like CanvasKit in your projects. See the "Getting Started" guide for more information.

Podfile

platform :ios, '7.0'
pod "CanvasKit", "~> 2.0"

2.0

CanvasKit 2.0 is a major refactor from the previous version of CanvasKit. Until now CanvasKit has only been used on internal projects at Instructure. One of our major goals of the recent refactor was to make CanvasKit open source and easy to use for third party developers.

Usage

Setup

In order to use CanvasKit with Instructure mangaged instances of Canvas LMS you must obtain a Client ID and Shared Secret. CanvasKit uses OAuth 2 for authentication. Request your Client ID and Shared Secret by sending an email to [email protected]. Make sure to give us your name, email, and what you are hoping to do with CanvasKit.

CKIClient

The CKIClient is in charge of all the networking in CanvasKit. Insantiate a CKIClient with your client ID and shared secret like so:

CKIClient *client = [CKIClient clientWithBaseURL:url clientID:ClientID sharedSecret:SharedSecret];

If the client is not logged in, you may do so by calling -login. This method will handle displaying a modal webview to the user and deal with the OAuth process for you. At the end you may look

[[self.client login] subscribeError:^(NSError *error) {
    // do somethign with the error
} completed:^{
    // login completed successfully. do something.
}];

If you would like to get information about the currently logged in user, you may do so by accessing the client.currentUser property. See CKIUser for more information.

Accessing the API

CanvasKit includes classes for many of the objects found in the Canvas LMS. Along with these model classes CanvasKit includes networking categories on CKIClient for accessing the API endpoints. For example, to fetch all the courses for the current user, you would do this:

[[client fetchCoursesForCurrentUser] subscribeNext:^(NSArray *courses) {
    // handle a page of courses
}];

Each networking method begins with 'fetch' making it easy for you to see all available options with Xcode auto-complete.

One thing to note is that CanvasKit uses ReactiveCocoa, however, it is not necessary to have any knowledge of ReactiveCocoa in order to use CanvasKit (although undertanding ReactiveCocoa will allow you to do much more powerful things). Each networking call returns a RACSignal object. Simply call subscribeNext: on that signal to process the data. Essentially the paginated data will be processed as a stream of pages, i.e. your subscribeNext: block will be called once for every page.

License

CanvasKit is available under the MIT license. See the LICENSE file for more info.

canvaskit's People

Contributors

armstrongnate avatar bdpluim avatar benkraus avatar bootstraponline avatar derrh avatar elgreco84 avatar jarsen avatar joshruesch avatar mileswright avatar ncperry avatar nlambson avatar

Watchers

 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.