Start a new topic

Wikitude - callJavaScript function

Wikitude - callJavaScript function


I have started using wikitude to show POI data. I would like to pass JSON data to wikitude's world.js.

So I created updateData() function in my poi javascript. And I am calling that function from another javascript by following .

1. I had to convert JSON to string in order to pass data to updateData() function.  Can I just pass JSON objects?

     var jsonStringData = JSON.stringify(jsobData).replace(/#/g, '"');

     WikitudePlugin.callJavaScript('updateData(''+jsonStringData +'\')');

If I use above method, I can pass data and poi gets loaded, but I can't pass more than 10 json object because of string limitation? not sure.

any help apprecieated.

Hi there!

Please ensure to encode your JSON data properly, so e.g. quotes don't mess up the JS call to the native webview.
String length shouldn't be an issue.

Kind regards,

Hi Andreas,

Thank you for looking into this.

so, currently I am replacing '"' with '#' sign to pass data properly and it works, but you mean I should not do that?

Instead of  var jsonStringData = JSON.stringify(jsobData).replace(/#/g, '"'); I can only do   var jsonStringData = JSON.stringify(jsobData);?

Well, if I don't replace '"' with something else, I cant pass data with callJavascript function.

Also, my json object is a bit bigger, and as I convert it to string, if I have more than 10 JSON objects, my JS function does not get invoked.

I am not using latest wikitude version, will that cause these issues?

Hi there!

Do you get any error after execution of the callJavaScript in the console?
I'd recommend you to test your POI data injection call in your desktop browser first. You may e.g. declare your method in an empty HTML / script-tag and use console to call the method incl. JSON parameter, or simply declare a dummy function in an existing webpage via debug-console (see attached pic, using page in Chrome Browser's console)
If you can access JSON data inside your method everything should also work inside ARchitectView's context.

Kind regards,


Hey Andreas,

I was able to load my JSON data after upgrading to wikitude 3.3. I was on 1.2 version and I think that might have issues.

So finally it worked by following code.

var jsonStringData = JSON.stringify(updatedLocations).replace(/#/g, '"');

WikitudePlugin.callJavaScript('updateData(''+jsonStringData +'\')');

Thank you for your help...
Login or Signup to post a comment