Languages

Menu
Sites
Language
sendCommand/SendMessage with parameters

Hi

Any idea where i could find some info how to implement SendCommand/SendMessage from web app javascript to native app c code with mutliple parameters ?

Thanks

Joe 

Responses

3 Replies
Shaswati Saha

Hello,
Would you please let me know what you're trying to achieve actually?
Are you trying to achieve your requirements by modifying the online samples(HybridService+HybridWebApp) or creating your own service(in native)
and UI(in web) app?

Marco Buettner

MessagePort allows only Strings, but u can use JSON.stringify() to wrap your JSON as String ... But dont forget to parse your JSON-String on Recieve again as JSON with JSON.parse()

You JSON can look like this

{
    parameter1: "anyString",
    parameter2: 25,
    parameter3: false
}

before you send convert your JSON to String

JSON.stringify({parameter1: "anyString", parameter2: 25, parameter3: false});

and on recieve convert your String back to JSON

JSON.parse(jsonString);