Start a new topic

Call PhoneGap functions from ARWorld

Call PhoneGap functions from ARWorld


Hi Nicola,

Yes I implemented according to those instructions.

It works well on Android but fails to work on iOS.

To be clear, the following line of code

app.wikitudePlugin.setOnUrlInvokeCallback(app.onURLInvoked);

has been run but iOS seems to not be picking up on the URL invokes.

Thank again for the quick response!

Regards,

Luis

Hi,

Does this knowledge base entry help?

Greetings

Nicola

Hi all,

I am able to close wikitude using architectsdk://action=somethinghere but only on Android.

On iOS this doesn't work; is there a setting (e.g. cordova's <meta http-equiv="Content-Security-Policy" content="gap:">) that would help enable the link?

Hope to hear back soon!

Regards,

Luis

 

Hi Alex,
You can't use any PhoneGap functions in ARchitect. If you need any information in ARchitect that you can get somehow from PhoneGap, you need to use the onURLInvoked function and the callJavaScript function of our Plugin.

I've copied the essential parts below. With the following snippets and the working sample code in the knowledge base article, you should be able to communicate between both context's.

PhoneGap

 

To register a callback function inside the PhoneGap context, use the `setOnUrlInvokeCallback` function.

 

app.wikitudePlugin.setOnUrlInvokeCallback(app.onURLInvoked);

 

Where `app.onURLInvoked ` is a function that is defined somewhere in the PhoneGap JavaScript context.

 

onURLInvoked: function(url) {

        

    // url could be 'architectsdk://closeWikitudePlugin' or 'architectsdk://buttonClicked'

       
          // to call back into ARchitect, use app.wikitudePlugin.callJavaScript('someJSFunctionORCodeThatIsEvaluatedInARchitectScope();');

    }

    

ARchitect World    

    

 After the PhoneGap setup part is done, the Architect World only has to call a function like the following whenever appropriate.

 

function closeWikitudePlugin()

{

    document.location = 'architectsdk://action=closeWikitudePlugin';

}

 


Best regards

Andreas

Hi Andreas,

Yes I know that they don't share the same scope but there must be a way to communicate both codes, thats why I use the architectsdk:// but I don't know if it's only for plugin calls. I've read the whole documentation but I still doesn't know how to do it. In theory, document.location should call the onUrlInvoke function but it doesn't. I suppose there is some way to use phonegap functions from the ARWorld, could someone post any example please? I've searched through all the Internet but I couldn't find a solution.

Hi Alex,
As far as I understood the code in code.js is part of your ARchitect World. Although the PhoneGap app and the ARchitect World are coded in JS, both can not directly communicate with each other and also they don't share the same global scope. This means that the navigator from PhoneGap is not available in an ARchitect World and the Safari Web Inspector should throw an error stating the error.

Please make yourself familiar with one of our knowledge base articles which describes the communication between PhoneGap & ARchitect in more detail.

Best regards

Andreas

Hello, I'm doing an app with Phonegap+Wikitude and I need to use the navigator.connection from the PhoneGap API (http://docs.phonegap.com/en/edge/cordova_connection_connection.md.html). I tried with a navigator.notification.alert but I couldn't make it work.

My code is the following:

index.js

   onUrlInvoke: function(url) {

        var scheme = 'architectsdk://';

        if (url.search(scheme) === 0) {

            // Remove architectsdk://from string and evaluate function

            var func = decodeURIComponent(url.substr(scheme.length));

            eval(func);

        }       

    }, 

 

code.js


navigateTo: function navigateFn(){

     document.location = "architectsdk://" + "navigator.notification.alert("+"It Works"+")";

}

 

The function navigateTo is called when a button is pressed from the ARWorld Interface but nothing happens. Despite of that, everything works fine.

 

How can I use Phonegap functions from my Wikitude project?

 

Thank you

 

 
Login or Signup to post a comment