返回插件列表

MicCore

核心插件。所有明源插件均基于此插件开发。为明源cordova工程必选核心插件

说明

核心插件中包含热更新插件,cordova官方新版白名单插件

插件新增参数SPLASH_LOADING,用来控制启动页是否显示loading标识,从3.1.6版本开始生效。

Android 说明

Android核心插件包含okhttp组件,fastjson组件, android-support-v4组件,org.apache.http.legacy组件(兼容6.0系统http api)

iOS说明

注意事项

MicCore.connect(
  function (result) {
    var code = result[0];
    if (code == 1200) {// 1200:存储权限获取失败
      // do something
    }
  },
  function (error) {
    console.log('error', error)
  }
);

目录

  1. 与插件保持长连接
  2. 关闭与插件的长连接
  3. 热更新
  4. 保持屏幕常亮
  5. sentry日志上传开关
  6. sentry保存自定义信息
  7. 关闭启动时对webview白屏内容监测
  8. 主动关闭启动页
  9. 设置页面字体大小
  10. 退出SDK
  11. 获取前端资源包绝对路径
  12. 获取SDK相关配置

APP模式接口

与插件保持长连接

MicCore.connect(success, error);
与插件保持长连接,使插件能够随时发消息给前端。
参数 类型 作用
success(result) Function 成功回调,长连接会话接收回调函数.result为数组。数组第一个下标是code码,第二下标是回调参数
error(obj) Function 错误回调,错误信息为json对象.例如 {errCode: -1, errMsg: "xxx"}

code码,回调参数列表说明

code码 说明 参数回调
102 广告页面点击事件 mads广告插件传进来的params原样回调给前端
103 广告页面点击跳过按钮事件 mads广告插件传进来的params原样回调给前端
104 涂鸦切换画笔颜色事件 返回int类型, 1:红色 2:黄色 3:白色
105 涂鸦画笔事件 无参数
106 涂鸦撤销画笔事件 无参数
107 重新拍照事件 无参数
108 涂鸦添加文字事件 无参数

关闭与插件的长连接

MicCore.close(success, error);
关闭连接。终止web与插件端会话
参数 类型 作用
success Function 成功回调
error(obj) Function 错误回调,错误信息为json对象.例如 {errCode: -1, errMsg: "xxx"}

热更新

MHotUpdate.downloadWebContent(zipUrl, success, fail, progress);
参数 类型 作用
zipUrl String web内容下载地址;zip格式,不加密
success() Function 更新成功回调
fail(error) Function 更新失败回调, error为json对象
progress(p) Function 下载进度回调,p为0-1之间的值

保持屏幕常亮

MicCore.keepScreenOn(screenOn, success, error);
参数 类型 作用
screenOn boolean true或false. true即保持常亮, 否则false.
success Function 成功回调
error(obj) Function 错误回调,错误信息为json对象.例如 {errCode: -1, errMsg: "xxx"}
// 调用示例
MicCore.keepScreenOn(
  true,
  function (result) {
    console.log('success', result)
  },
  function (error) {
    console.log('error', error)
  }
);

sentry日志上传开关

MicCore.sentryLogSwitch(isOff, success, error, options);
参数 类型 作用
isOff boolean 是否关闭上传,默认为false
success Function 成功回调
error(obj) Function 错误回调,错误信息为json对象.例如 {errCode: -1, errMsg: "xxx"}
options JSONObject 可选参数,目前仅提供info_switch_on可使用。
// 调用示例
MicCore.sentryLogSwitch(
  true,
  function (result) {
    console.log('success', result)
  },
  function (error) {
    console.log('error', error)
  }
);

options参数说明

参数 类型 作用
info_switch_on boolean 设置上传信息类别日志,默认false.

sentry保存自定义信息

MicCore.saveBusiness(businessID, success, error);
参数 类型 作用
businessID String 定位各业务系统唯一用户,如:企业号_用户名。用于排查插件问题时联系客户。
success Function 成功回调
error(obj) Function 错误回调,错误信息为json对象.例如 {errCode: -1, errMsg: "xxx"}
// 调用示例
MicCore.saveBusiness(
  saveBusiness,
  function (result) {
    console.log('success', result)
  },
  function (error) {
    console.log('error', error)
  }
);

关闭启动时对webview白屏内容监测

白屏内容监测机制原由:程序启动时,会先显示程序启动页,当启动页消失后,因webview还没有完全加载前端页面,因webview没有内容,给用户一种白屏效果,体验不佳;

解决方案:在屏幕最上层遮盖一层假的启动页,然后将webview的内容截屏成图片,按网格遍历图片上的像素点颜色值,如果颜色值不是纯白色或者纯黑色,则认为webview内容已经加载完毕,插件主动隐藏假的启动页;

超时机制:若监测时间超过20秒,对webview内容遍历像素点颜色值还是纯白或者纯黑,则会触发超时机制,插件主动隐藏假的启动页。

前端主动关闭开启/机制:调用此方法传入值在本地存入,下次启动时,将会取此值判断是否开启 or 关闭。

MicCore.stopSplashMonitor(stop, success, error);
参数 类型 作用
stop bool true:关闭,false:不关闭,默认false。
success Function 成功回调
error(obj) Function 错误回调,错误信息为json对象.例如 {errCode: -1, errMsg: "xxx"}
// 调用示例
MicCore.stopSplashMonitor(
  true,
  function (result) {
    console.log('success', result)
  },
  function (error) {
    console.log('error', error)
  }
);

主动关闭启动页(3.0.3+版本生效)

MicCore.closeSplashScreen(success, error);

1. 由于原生端对于前端页面加载完成的判断可能存在偏差,所以提供该接口便于前端在合适的时机关闭启动页。

2. 调用该接口需在添加插件时设置参数NOT_CHECK_SPLASH_SCREENtrue,否则原生端也会对前端页面是否加载完成进行检测。

// 调用示例
MicCore.closeSplashScreen(
  function (result) {
    console.log('success', result)
  },
  function (error) {
    console.log('error', error)
  }
);

设置页面字体大小(3.0.6+版本生效, 仅支持Android)

MicCore.setTextZoom(textZoom, success, error)
参数 类型 作用
textZoom int 100为默认大小,>100为放大,<100为缩小
success Function 成功回调
error(obj) Function 错误回调

注意: 该接口无需重复调用,在设置过后,重新打开APP时会使用上一次设置的值

// 调用示例
MicCore.setTextZoom(
  100,
  function () {
    console.log('success')
  },
  function (error) {
    console.log('error', error)
  }
);

退出SDK(3.1.1+版本生效)

MicCore.exitSdk(success, error)
参数 类型 作用
success function 成功回调
error(obj) function 错误回调
// 调用示例
MicCore.exitSdk(
  function () {
    console.log('success')
  },
  function (error) {
    console.log('error', error)
  }
)

获取前端资源包绝对路径(3.1.1+版本生效)

MicCore.getWebPath(callback)
参数 类型 作用
callback(path) function path为前端资源包本地存储的绝对路径,string类型
// 调用示例
MicCore.getWebPath(
  function (path) {
    console.log('path', path)
  }
)

获取SDK相关配置(3.1.1+版本生效)

MicCore.getSdkConfig(callback)
参数 类型 作用
callback(config) function config为sdk相关参数
// 调用示例
MicCore.getSdkConfig(
  function (config) {
    console.log('config', config)
  }
)
// config结构说明
{
    "isSdk": true, // 当前是否为sdk环境
    "sdkArgs": {}, // 调用方唤起sdk时的传参
    "sdkVersionCode": "1.0.0" // sdk版本号
}