IPCUtil

最低版本: 2.1.0最后更新: 2021/1/22

类说明:

跨 OPK IPC API 调用,需要目标 OPK 当前在前台。

 

支持平台:

平台是否支持
豹小秘
豹大/花瓶
豹小秘Mini

 

 

方法:

方法名参数JS类型必填参数说明方法说明最低版本支持平台
豹小秘豹大/花瓶豹小秘 Mini
syncCallFunctiontargetAppIdstring目标 opk 的 appId跨 OPK 同步调用方法2.1.0
callableModulestring目标 opk 注册的 module
callableMethodstring目标 opk 注册的 method
paramstring调用方法参数
asyncCallFunctiontargetAppIdstring目标 opk 的 appId跨 OPK 异步调用方法2.1.0
callableModulestring目标 opk 注册的 module
callableMethodstring目标 opk 注册的 method
paramstring调用方法参数

示例代码:

// 在 appId: xxx1234 的 opk 中注册 module 和 方法

 

import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
 

BatchedBridge.registerCallableModule(
    'TestModule',
    TestModule
);

 

class TestModule {

   public static testMethod(callerId: string, param: string) {

      console.log(callerId,param);
   }

}

 

 

// 在另外一个 opk 中调用方法

 

import { IPCUtil } from 'orionos-eve-core';
 

let callFunctionResult = IPCUtil.syncCallFunction(
    'xxx1234',
    'TestModule',
    'testMethod',
    JSON.stringify({

        key1:89,

        kery2:'string value'

    })
);
console.log(
    TAG,
    'syncCallFunction TestModule testMethod result',
    callFunctionResult
);