Hi,
I created my own plugin where I need to transfer byte arrays from Ionic to iOS (Swift) process them and afterwards back to Ionic.
Ionic → ByteArray → iOS → ByteArray → Ionic
So I created an interface function in the
definitions.ts
transceive(data: Uint8Array): Promise<{ result: Uint8Array }>;
My iOS code looks like the following:
Plugin.swift
@objc func transceive(_ call: CAPPluginCall) {
print("transceive()")
let dataReceived = call.getObject("data")! //crashes
print(dataReceived)
//do something with the byte array
call.resolve(["result": dataReceived]) // return byte array
}
My code in Ionic looks like this:
ionic.ts
const test = new Uint8Array([0x90, 0x71]);
const result = await CapacitorPlugin.transceive({ data: test });
Is that possible in Capacitor 2 or do I need to transfer strings and convert them to byteArrays at each endpoint?
Thanks in advance
Max