返回介绍

Ionic4 Class Kit插件-Class Kit

发布于 2019-11-23 07:40:58 字数 4496 浏览 922 评论 0 收藏 0

Plugin for using Apple's ClassKit framework.

Prerequisites: Only works with Xcode 9.4 and iOS 11.4. Your Provisioning Profile must include the ClassKit capability. Read more about how to Request ClassKit Resources (https://developer.apple.com/contact/classkit/) in here: https://developer.apple.com/documentation/classkit/enabling_classkit_in_your_app. Also note that you can’t test ClassKit behavior in Simulator because Schoolwork isn’t available in that environment.

https://github.com/sebastianbaar/cordova-plugin-classkit.git

Ionic Class Kit插件的安装(Installation)

ionic cordova plugin add cordova-plugin-classkit npm install @ionic-native/class-kit 
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/class-kit 

Ionic Class Kit插件支持的平台(Supported Platforms)

  • iOS

Ionic Class Kit插件的用法(Usage)

import { ClassKit, CCKContext, CCKBinaryItem, CCKQuantityItem, CCKScoreItem, CCKContextTopic, CCKContextType, CCKBinaryType } from '@ionic-native/class-kit/ngx';

// Init contexts defined in XML file 'CCK-contexts.xml'
constructor( ..., private classKit: ClassKit) {
  platform.ready().then(() => {
    classKit.initContextsFromXml("classkitplugin://")
      .then(() => console.log("success"))
      .catch(e => console.log("error: ", e));
  });
}

...

// Init context with identifier path
const context: CCKContext = {
  identifierPath: ["parent_title_one", "child_one", "child_one_correct_quiz"],
  title: "child one correct quiz",
  type: CCKContextType.exercise,
  topic: CCKContextTopic.science,
  displayOrder: 0
};

this.classKit.addContext("classkitplugin://", context)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Remove all contexts
this.classKit.removeContexts()
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Remove context with identifier path
this.classKit.removeContext(["parent_title_one", "child_one", "child_one_correct_quiz"])
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Begin a new activity or restart an activity for a given context
this.classKit.beginActivity(["parent_title_one", "child_two", "child_two_quiz"], false)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds a progress range to the active given activity
this.classKit.setProgressRange(0, 0.66)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds a progress to the active given activity
this.classKit.setProgress(0.66)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds activity information that is true or false, pass or fail, yes or no
const binaryItem: CCKBinaryItem = {
  identifier: "child_two_quiz_IDENTIFIER_1",
  title: "CHILD TWO QUIZ 1",
  type: CCKBinaryType.trueFalse,
  isCorrect: isCorrect,
  isPrimaryActivityItem: false
};

this.classKit.setBinaryItem(binaryItem)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds activity information that signifies a score out of a possible maximum
const scoreItem: CCKScoreItem = {
  identifier: "total_score",
  title: "Total Score :-)",
  score: 0.66,
  maxScore: 1.0,
  isPrimaryActivityItem: true
};

this.classKit.setScoreItem(scoreItem)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Activity information that signifies a quantity
const quantityItem: CCKQuantityItem = {
   identifier: "quantity_item_hints",
   title: "Hints",
   quantity: 12,
   isPrimaryActivityItem: false
};

this.classKit.setQuantityItem(quantityItem)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文