Canvas library for Cocoa.
Objective-C Swift C JavaScript Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
CanvasKit.xcodeproj
CanvasKit.xcworkspace
CanvasKit
CanvasKitTests
Example
.gitignore
Cartfile
Cartfile.resolved
LICENSE.md
README.md
Rakefile

README.md

CanvasKit by Instructure iOS

End Of Life


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 mike@instructure.com. 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.