An area of your app that represents an assignable task, like a quiz or a chapter.


class CLSContext : CLSObject


Configure contexts with enough information to make it easy for teachers to understand what app content the context represents. For example, make sure each context has a title that is clear, concise, and localized for any region that your app supports.

A context can also contain a grouping of other contexts, like a book that contains chapter contexts or a chapter that contains section contexts. You can assemble contexts into a hierarchy, up to eight levels deep, that acts as a sort of table of contents for teachers who want to assign your app content. See Advertising Your App’s Assignable Content for more details.


Creating Contexts

class CLSObject

The abstract base class for objects managed by ClassKit.

Configuring a Context

var title: String

The name of the context as it appears to users.

var identifier: String

A string that uniquely identifies a context among its siblings.

var type: CLSContextType

The kind of content a context represents.

enum CLSContextType

The kinds of assignable content a context can contain.

Managing Context Presentation

var displayOrder: Int

The position of a context relative to its siblings.

var topic: CLSContextTopic?

The area of study to which a context relates.

struct CLSContextTopic

The areas of study to which contexts may relate.

Activating and Deactivating a Context

Informing ClassKit That a Task Is About to Begin

Activate and deactivate contexts according to user interaction.

func becomeActive()

Tells a context to become the active context.

func resignActive()

Tells a context to stop being the active context.

var isActive: Bool

A Boolean indicating whether the context is active.

Creating Activities

var currentActivity: CLSActivity?

The activity available for recording progress.

func createNewActivity() -> CLSActivity

Creates and returns a new activity instance for the context.

Managing Context Hierarchy

var parent: CLSContext?

The direct ancestor of this context.

func removeFromParent()

Removes the context from its parent.

func addChildContext(CLSContext)

Adds the specifed context as a child of the context receiving the method call.

func descendant(matchingIdentifierPath: [String], completion: (CLSContext?, Error?) -> Void)

Finds the context with the given identifier path relative to this context.

Configuring Deep Links

Linking Directly to Assignments

Make it easy for teachers to guide students to specific content.

var universalLinkURL: URL?

A URL that leads to the content in your app associated with the current context.

var isClassKitDeepLink: Bool

Indicates whether a user activity represents a ClassKit context.

var contextIdentifierPath: [String]?

The identifier path associated with a user activity generated by an app that adopts ClassKit.


Inherits From

Conforms To

See Also


Advertising Your App’s Assignable Content

Assemble a hierarchy of contexts and declare your app’s assignable content.

protocol CLSContextProvider

An interface used to tell your ClassKit context provider app extension to update contexts.