Class

CLSContext

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

Declaration

class CLSContext : CLSObject

Overview

Make it easy for teachers to understand the app content a context represents by configuring it with information like a clear, concise title localized for the regions that your app supports.

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

Topics

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.

var customTypeName: String?

An optional name that the system presents to the user if you choose the custom context type.

Beta

Characterizing the Context

var summary: String?

An optional, user-visible description of the context.

Beta
var thumbnail: CGImage?

An optional thumbnail image associated with the context.

Beta

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 identifierPath: [String]

The identifier path that locates the context within the data store’s context hierarchy.

Beta
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.

Relationships

Inherits From

Conforms To

See Also

Contexts

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software