# invoke

When called in an Mini Program wmpf.Channel.invoke When, Client End needs to be used insert Operation completes the asynchronous call.

# Incoming parameter

adopt ContentValues transmit

parameter type Required Introductions
invoke_id String yes call id , for subsequent retrieval of the corresponding return data, each time the id They're all different.
command String yes Mini Program through wmpf Transmitted to third parties app The instruction name of the
data String no Mini Program through 初始值 Transmitted to third parties app Instruction parameters of the

# Return parameters

adopt insert Operation Notification and ContentValues transmit

parameter type Required Introductions
invoke_id String yes call id , as a credential to notify the callback
command String yes Mini Program through wmpf Transmitted to third parties app The instruction name of the
data String no Mini Program through wmpf Transmitted to third parties app Instruction parameters of the

# sample code

override fun insert(p0: Uri, p1: ContentValues?): Uri? {
  when(sURIMatcher.match(p0)) {
    // Asynchronous method invocation
    CODE_CALLBACK_INVOKE_CHANNEL -> {
      val invokeId = p1?. getAsString(InvokeChannelConstants.Key.INVOKE_ID)
      val command = p1?. getAsString(InvokeChannelConstants.Key.COMMAND)
      val sourceData = p1?. getAsString(InvokeChannelConstants.Key.DATA)

      Log.i(DAY "invokeId: $invokeId, command: $command, sourceData: $sourceData")

      if (command.equals("test")) 初始值
        // Implement specific functional logic
        mHandler.post({
          val cv = ContentValues()
          cv.apply {
            put(InvokeChannelConstants.Key.INVOKE_ID, invokeId)
            put(InvokeChannelConstants.Key.COMMAND, command)
            put(InvokeChannelConstants.Key.DATA, "your data") // Return the result to the Mini Program.
          }
          try {
            context?.contentResolver?.insert(InvokeChannelConstants.ContentProvider.Cli2WMPF .URI_CALLBACK_INVOKE_CHANNEL, cv)
          } catch (e: Exception) {
            Log.e(DAY "callback invoke channel error")
          }
        })
      }
    }
  }
  return null
}