客户端接口 - (v1)invokeSync

invokeSync

当小程序中调用 wmpf.Channel.invokeSync 时,Client 端需要使用 call 操作完成同步调用。

传入参数

command 对应 call 方法的 「method」 字段,data 对应 call 方法的 「arg」 字段

参数 类型 必填 说明
command String 小程序经 wmpf 透传给第三方 app 的指令名
data String 小程序经 wmpf 透传给第三方 app 的指令参数

返回参数

通过 Bundle 返回

参数 类型 必填 说明
data String 第三方 app 经 wmpf 透传给小程序的调用返回结果

示例代码

// 同步调用
override fun call(method: String, arg: String?, extras: Bundle?): Bundle? {
  Log.i(TAG, "method: $method, arg: $arg, extras: $extras")
  // 实现特定的功能逻辑
  val bundle = Bundle()
  bundle.putString("data", "call success, method: $method, arg: $arg, extras: $extras")
  // 返回执行结果给小程序端
  return bundle
}
posted on 2025-02-24 15:48  AtlasLapetos  阅读(8)  评论(0)    收藏  举报