Start a new topic

How to Exit World in Wikitude

How to Exit World in Wikitude


Hi Andreas,

Yes, of course I can, actually I already did it:

I got a Wiki OK when .hide() is called, but the world is not being hidden, the camera image is still active.

Then I got a Wiki Error when .show() is called (maybe because it is actually not hidden?)

Any help would be appreciated!

Thanks and best regards,

Marton

 

Hi Marton,
I just tested hide() & show() with our latest Wikitude Cordova plugin and Wikitude Cordova example application.

I changed our first example so that it uses the onEnterFieldOfVision trigger to change the document location to:

 

This will then trigger a call to the onUrlInvoked function in your cordova index.js file. There, I just added a call to hide() and show().

What then happens is, that if you open the first example and recognize the target, our plugin is hidden and after one second shown again.

Here is the modified onUrlInvoked function:

```

onUrlInvoke: function (url) {
if (url.indexOf('captureScreen') > -1) {
app.wikitudePlugin.captureScreen(
function(absoluteFilePath) {
alert("snapshot stored at:n" + absoluteFilePath);
},
function (errorMessage) {
alert(errorMessage);
},
true, null
);
} else {
//alert(url + "not handled");
app.wikitudePlugin.hide();
setTimeout(function(){app.wikitudePlugin.show();}, 1000);
}
}

```

I tested it with an Android 5 device and our latest SDK + Cordova extension. Which hardware & Wikitude sdk version are you using?

Best regards,

Andreas

Dear Andreas,

Thanks a lot for your extensive support!

Since then, we decided to develop our AR project on Unity and Vuforia, but its good to know that it's working. :)

Thanks again,

Marton

Hi Marton,
In case you want to continue using the Wikitude SDK also in Unity, we just released an update to our Unity plugin which contains a lot of improvements ;)

Best regards,

Andreas

Hi Andreas.

This fix works great. Just a very simple question from here on:

on the onURL Invoked method, after we close the plugin, would a simple window.location('index.html');

change the path of where the app is?

Hi Joao,
By 'where the app is' you refer to if the Cordova or Wikitude Plugin view is displayed or which web page is loaded (in either Cordova or the Architect web view)?

If your question is about how to close the Wikitude Plugin, you need to call something like app.wikitudePlugin.close();. Changing the window location does not affect if our plugin is shown or not.

I'm not quite sure if I understood your question correctly, so please don't hesitate to follow up with a new question.

Best regards,

Andreas

Hi Andreas!

Thank you for your answer and I apologize for the "newbie language" used. And yes, I want the app to navigate to a different page in the cordova view once I close the ARchitect View.

The ARchitect View already closes. However, it goes back to the HTML file that had the index.js embedded. Should I post a different question for that?

Once again, thank you very much for your help. This post has helped me more than the last 2 days of searching :)

Hi Joao,
Once the Architect View is closed, navigating in the cordova application can be done independently from the Wikitude Plugin. I'm not a expert in web development, but I heard/read that changing the location might not be the most elegant solution. I could forward the question to our web devs if you want to, they should be able to help you out.

Does calling the 'close' function of our SDK trigger a page redirection/reload of the cordova application? Was there a different page loaded at the moment when you 'opened' the Wikitude Plugin?

Best regards,

Andreas

Hi Andreas.

That would be great if you could redirect it.

What happens is that I embedded the index.js in a page, and the index.js file has the URL for the Architect View, which naturally is a different page. I used the method you described (app.WikitudePlugin.close()) and it works, and again naturally, it goes back to the page where the the index.js was embedded.

 

Best Regards,

Joao Pratas

Hi Joao,

I guess I understood now:  What you want is that after the Wikitude Plugin is closed, a different page is shown in the cordova application?

Best regards,

Andreas

Hi Andreas.

Exactly. I'm creating a game with a quite linear navigation and the ARchitect View should then lead the user to a different page. :)

Regards,

Joao

Hi Joao,
did you tried to call document.location = 'your/custom.html' instead of window.location (in your cordova js file that closed the wikitude plugin)?

Best regards,

Andreas

Hi Andreas.

Yes I just tried it and it still doesn't work. I was trying to redirect the app to the start of the application, but not successfully.

My guess is that it's something that has to do with the way i set this up in javaScript:

 

onURLInvoked: function(url) {

app.wikitudePlugin.close();
document.location('../index.html');
},

 

something tells me that that URL at the top has to come from somewhere.

Any suggestions?

Regards,

Joao

The url that is passed to the onURLInvoked method is the one you assigned in your architect world when calling document.location = architectsdk://.

The relative path that you used in the snippet refers to the main cordova .html file. are you sure that this is the correct path?

Best regards,

Andreas

Hi Andreas.

Yes, the test I was doing with the relative path would direct the app to the main cordova file (and that is close to the path I want the app to go to, given that the directory is the same).

In my ARchitect World HTML file i call the sdk to close it like this:

<script>
function closeWikitudePlugin(){
document.location = 'architectsdk://action=closeWikitudePlugin';
document.location('../index.html');
}
</script>

 

the document.location with the relative path was just added to desperately try and solve this (needless to say, not successful), however this is the way I'm calling it.

 

Regards,

Joao
Login or Signup to post a comment