Package - blockdate/ios-rn-sdk GitHub Wiki
扩展程序包参数, 主要来自于packageInfo.json 的配置与系统本身的特性
Export:
Example
import {Package} from 'miot'
import Package from 'miot/Package'
Package.entrance
Package.entryInfo
Package.exitInfo={...}
Package.pluginID
Package.packageID
Package.packageName
Package.version
Package.minApiLevel
Package.buildType
Package.isDebug
Package.models
Package.entry(App, ()=>{...});
Package.exit({...});-
miot/Package
-
module.exports ⏏
-
static
-
.exitInfo :
json -
.entrance :
Entrance -
.entryInfo :
json -
.packageID :
int -
.version :
string -
.packageName :
string -
.minApiLevel :
int -
.buildType :
string -
.isDebug :
boolean -
.models :
string - .entry(RootComponent, afterPackageEntry)
- .exit(info)
-
.exitInfo :
- inner
-
static
-
module.exports ⏏
退出后返回给调用者的信息, 例如自定义场景
Kind: static property of module.exports
Example
//自定义trigger场景保存退出 finishCustomSceneSetupWithTrigger
var trigger = Package.entryInfo;
trigger.payload = { 'xxx': 'xxx' };//trigger payload 数据
Package.exitInfo = trigger; // 设置exitInfo之后插件就会正常退出,无需再调用 Package.exit();
//自定义action场景保存退出 finishCustomSceneSetupWithAction
var action = Package.entryInfo;
action.payload = { 'xxx': 'xxx' };//action payload 数据
Package.exitInfo = action; // 设置exitInfo之后插件就会正常退出,无需再调用 Package.exit();入口类型
Kind: static constant of module.exports
Read only: true
入口信息
Kind: static constant of module.exports
Read only: true
小米开放平台生成的插件包 ID
Kind: static constant of module.exports
Read only: true
程序包的版本号, 来自于project.json 的 version
Kind: static constant of module.exports
Read only: true
程序包名, 来自于project.json 的 package_name
Kind: static constant of module.exports
Read only: true
扩展程序适用的最低 API level, 来自于project.json 的 min_api_level
Kind: static constant of module.exports
Read only: true
发布类型, debug | release
Kind: static constant of module.exports
Read only: true
判断是否是调试版本
Kind: static constant of module.exports
Read only: true
适配的固件 model, 来自于@link packageInfo.json 的
Kind: static constant of module.exports
Read only: true
系统入口
Kind: static method of module.exports
| Param | Type | Description |
|---|---|---|
| RootComponent | React.Component |
入口的React Component模块 |
| afterPackageEntry | function |
进入后, RootComponent 加载之前执行, 缺省为空 |
Example
import SceneMain from '...';
import App from '...';
import {Package, Entrance} from 'miot';
switch(Package.entrance){
case Entrance.Scene:
Package.entry(SceneMain, ()=>{...});
break;
default:
Package.entry(App, ()=>{...});
break;
}强制退出插件
Kind: static method of module.exports
| Param | Type | Description |
|---|---|---|
| info | * |
如果不为空, 则等同于设置 Package.exitInfo |
扩展程序调用的入口类型
Kind: inner namespace of module.exports
主入口
Kind: static constant of Entrance
场景入口
Kind: static constant of Entrance
Package事件名集合
Kind: inner namespace of module.exports
Example
import {PackageEvent} from 'miot'
const subscription = PackageEvent.packageWillPause.addListener(()=>{
...
})
...
subscription.remove()
...-
~PackageEvent :
object
插件将要加载
Kind: event emitted by PackageEvent
插件加载完成事件
Kind: event emitted by PackageEvent
插件将暂时退出前台事件
Kind: event emitted by PackageEvent
插件将重回前台事件
Kind: event emitted by PackageEvent
用户撤销隐私授权时的回调
Kind: event emitted by PackageEvent
插件接收到场景等通知消息
Kind: event emitted by PackageEvent
插件将退出事件
Kind: event emitted by PackageEvent
从 Native 界面返回到插件,可以通过监听此事件更新已加载过的视图,或进行相应的事件处理。
Kind: event emitted by PackageEvent