Start a new topic

callJavascript working partially cordova plugin 5.3.1

Hello there. I'm calling callJavascript in my Ionic page and sometimes it work, sometimes it doesn't. To be more specific if I call an alert or something like this it works:  


     this.wikitudePlugin.callJavaScript('alert(\'callJavascriptCalled\')');


but if I try to call a function that is defined in the world's context like this, it doesn't work


     this.wikitudePlugin.callJavascript('World.init()');


I did some debugging in chrome at strangely it gives me this error where it says that callJavascript is not  function:


cordova.js:314 Uncaught TypeError: this.wikitudePlugin.callJavascript is not a function

    at HomePage.webpackJsonp.105.HomePage.onARExperienceLoadedSuccessful (main.js:68)

    at main.js:48

    at Object.callbackFromNative (cordova.js:293)

    at <anonymous>:1:9


This is in a project using the version 5.3.1 of the cordova plugin. I have exactly the same code in an app using version 6.something where it does work. Any help is welcome, best regards:


Axel 

 


 



HI Raphael, thank for your answer but I don't see the difference between what you proposed and what I did. Besides that I'm using Ionic then I call "this" instead of "app" to call the wikitude plugin our lines of code are the same. As I said in the post this line works in the cordova plugin v6, it seems to not to be working in the version 5.3.1 so if anybody has some 5.3.1 experience we'd appreciate, regards:



Axel

hi, maybe try something like :

app.wikitudePlugin.callJavascript('World.init()');


we use the callJavascript in our code (plugin v6.0.0 and v7.2.1) but we call a function outside the World object.

app.wikitudePlugin.callJavascript('setUserInfo()');



1 person likes this
Login or Signup to post a comment