Start a new topic

How to Exit World in Wikitude

How to Exit World in Wikitude


I have this code in my Video.js, in the method onFinishedPlaying:

document.location = 'architectsdk://onUrlInvoke?gacode=B001&status=1';

In my AR.js, I have this code:

cordova.exec(function () {

  cordova.exec(function (){database.update("ar_games", {code: 'B001'}, function(row) {

row.status = "1";return row;

 });

database.commit();

   //

 var ref = window.open("Games/fruitcatcher/index.html", '_system', 'location=yes');

 alert('Game Activated!');

}, arApp.onWikitudeError, "WikitudePlugin", "close", );

  

  }, arApp.onWikitudeError, "WikitudePlugin", "onUrlInvoke", );    

});

}

 

When the video is finished, I want the app to exit the world to a given html file. After the video is finished, the app goes back to my previous html file, with the alert, then goes to the location assigned in the ref variable. Works like a charm.

 

However, I created a div on the camera scene, like the div at the top of the screen in your examples that says "Point to target".

That div is a back button. I created that back button for iOS since IPhones don't have a back button. In the onclick of the back button div, I have this code:

 

document.location = 'architectsdk://actionButton?action=close'

 

When I click the button, the behavior is the same, the app goes back to my previous html file, with the alert, then goes to the location assigned in the ref variable. The problem is, I designed the app that when the alert is shown, the Video.js or the AR view will not be called anymore. Is there a way to just go back and not go to a url base on onUrlInvoke? Thanks.

 

 

 

Hi Miguel,
I don't know if I understand your problem correctly, but du you know the 'hide' function, defined in the WikitudePlugin.js?
It simply hides the Wikitude SDK view but keeps the state as it is. You can then resume, using the 'show' function.

Best regards

Andreas

I tried hide function but still that is not the behavior I wanted. On the onUrlInvoke that I have: 

document.location = 'architectsdk://onUrlInvoke?gacode=B001&status=1

And my hide function:

document.location = 'architectsdk://hideButton?status=hide';

 

Is there anything wrong with my hide function? Is there a way to pass a different gacode or status parameter? It always redirects to the onUrlInvoke function in my AR.js.

 

Regards,

Miguel

After searching, I haven't found anything that will comply to the back behavior I wanted. However, the Android Device Button Works just fine. I checked that there are codes in WikitudePlugin.java . Is there a way to call the method removeArchitectView(); 

from the WikitudePlugin.java in my index.html?

I have a div on the html,which is present on the AR view that handles the "going back" function:

<div id="backButton"  class="bottom" onclick="document.location = 'architectsdk://actionButton?status=hide';"><img width='25%' src='backbutton.png'></div>

I hope you can give me response.


Thanks,  

Miguel

I still need to figure this out. I can send some files for you to look at it. We need a back button for iOS version of the app. WE BOUGHT A LICENSE AND WE WOULD LIKE TO RECEIVE SUPPORT FROM YOU. I need a way to determine the parameters in urlinvoke. Thanks.

Hi, 
please excuse my late response but we're preparing a new SDK release which requires a lot focus on testing and polishing.

I've create two files for you, index.js which is the main entry point for the PhoneGap application and SimpleCircle.html which contains the ARchitect World.
        

app.wikitudePlugin.setOnUrlInvokeCallback(app.onURLInvoked); // Here we register a function (app.onURLInvoked) which will be called everytime a 'architectsdk://' url should be loaded. 

The impl. of 'app.onURLInvoked' is quiet simple.

onURLInvoked: function(url) {

        

    // TODO: impl. url parsing to know what to do with the given url.

        

    app.wikitudePlugin.close()

}

You can use the wikitudePlugin.close function to close the AR view when the url is e.g. architectsdk://hideButton?status=hide. You simply need to add url parsing (which is done in plain js) to distinguish between different url invokes. 

Inside SimpleCircle.html, a function is binded to a button click. The function is shown below:

function sendCloseARViewRequest()

{

    // hideButton?status=hide could be anything, you just have to know what to do with the url in the PhoneGap world.

    document.location = 'architectsdk://hideButton?status=hide';

}

It simply calls document.location with the ARchitect SDK scheme and some user defined parameters.

 

I hope this is helpful for you!

Best regards

Andreas

Hi Andreas!

Good News is that I can parse the url now. Yey! However, the client wants the app to support at least IPhone 4 and Ipod Touch 4th Gen. Is there any workaround to make the app work on those device? When I launch the AR World it calls onArchitectWorldFailedLaunching and displaying an alert error Error. 

 

Thanks! 

 

Miguel

Hi,
The iPod Touch 4th gen is not supported. It's missing device sensores for geo AR and is way to slow for IR. The iPhone 4 should be able to run Geo as well as IR worlds. Have you check the result of the 'isDeviceSupported' function? Depending on the content of your ARchitect World, you can alter the 'arMode' variable inside WikitudePlugin.js to refine the kind of ARchitect World that should be loaded.
onArchitectWorldFailedLaunching will be called when the ARchitect world itself can not be loaded from either the application bundle or the specified URL. That has nothing to do with the device capabilities (see isDeviceSupported function).

Best regards

Andreas

Dear Andreas,
Your example helped me more than the previous 4 hours of searching.
Thanks!

Hi Marton,
You're welcome :) It's always nice to hear that the forum is helpful for others!

Do you know about the knowledge base article which is related to this?

Best regards

Andreas

Hi Andreas,

Thanks for your kind reply, its good to know, I haven't found this article earlier, but now it already works perfectly.

I may have a suggestion, you can include  a very simple URL parser for the callback function if you feel like, that would make handling the returned data even more comfortable.

I use this one and its working very nice.

Thank you and best regards,

Marton

 

Hi Marton,
Thx for sharin the URL parser. We will discuss internally if we include the library or not.

Best regards

Andreas

Dear Andreas,

I would have a question: I just cant figure out why my wikitudePlugin.hide() call is not working.

I would use it in my onUrlInvoke callback, which otherwise runs fine.

Within this callback, the wikitudePlugin.close() works perfectly and closes down the camera view but the wikitudePlugin.hide() just doesn't do a thing. (Using Wikitude phonegap plugin 5.1.4 on Android)

What am I doing wrong? :)

Thanks for your help in advance!

Marton

Hi Marton,
Can you add some alerts in the WikitudePlugin.js function onWikitudeOk and onWikitudeError? The hide method is implemented on Android and should report an error if something unexpected happens internally.

Best regards

Andreas
Login or Signup to post a comment