cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Vuforia Studio Crashes while opening an URL

mziemniewicz
9-Granite

Vuforia Studio Crashes while opening an URL

Hello everyone, I'm trying to solve an interesting issue:

Experience created in Vuforia Studio for mobile device (iPhone) crashes while opening an url which responds any other code than 200. In my particular case I try to launch a login web page of my system using Vuforia View.
After that login web page (using oidc) redirects me back to my experience. Works fine only for happy path (response code 200). Any other responce code (example wrong password like 400, 500 etc) causes Vuforia View app crash.

Has anyone ever encountered this problem?

The method I'm using is:
window.location.href= ' ' + url;

2 REPLIES 2

Hi @mziemniewicz ,

do you mean a real crash? or the vuforia view app  goes back to scan mode?

Why I am asking - because currently I have an  issue where the description is similar to your description but there the app does not crash / unexpected exit of the app/ but it goes back to scan mode.

The current problem occurrence there is the following:

  • When setting the url / displaying an url  via
window.location.href= ' ' + url;

 and the response code is != 200 /OK  - in this case the Vuforia View app goes back to scan mode but no real crash could be observed.

First thig I want to mention here is that using some link which is pointing to somewher  else (not the ES and IOT url and domain)  is not that what the window.location for this application expects, and may be was not  
So when for example an experience on ES returns a different form OK code it will automatically lead to go back to scan mode. This seems to be currently the intention of the current implementation. 

Mostly is this working and  you can simple do a check of the link . The following code will prevent that a Vuforia View App will go back to scan mode. You need simple to check what the url will return, so simiple check your URL before you try to set it to the window.locaiton.href
Example Code:

$scope.redir = function (url) {
  console.log('redir ' + url);
console.log("for testing will print window.locaton");
  
 
  
  fetch('http://getstatuscode.com/' + url).then(response => {
 
if (response.ok) { // if HTTP-status is 200-299
  twx.app.fn.addSnackbarMessage("response.OK","twLogo");
window.location.href='http://getstatuscode.com/' + url; 
//$scope.$applyAsync();
} else {
  let txtE="response Status: " + response.status
  //alert(txtE);
   console.error( txtE);
   twx.app.fn.addSnackbarMessage(txtE,"twLogo");
// twx.app.fn.navigate('Home');
}
 
}).catch(error =>{ console.error(error);
                    let txtW="response Status: " + error
                      twx.app.fn.addSnackbarMessage(txtW,"twLogo");
                    // alert(testW);
                   //  twx.app.fn.navigate('Home');
                  })
}
//===============

 

So in this code we will set the URL to the window.locaiton.href only when the response is OK.

Currently when we set a window.locaiton.href to an URL it will show the url in the current main panel of the Vuforia View app. 

BUT... this behavior will change when we add a hyperlink widget to the Studio project. In this case it will always load the URL in the external browser /device browser.

Here we do not have the issue anymore! But we have an issue with the sending back of data form the external URL.

One possible solution for the problem with passing of arguments (info from dev team):

 

url parameters need to be url encodeded, maybe that is causing the grief?

Also, generally would prefer to use `https://view.vuforia.com/command/view-experience` instead of `thingworxview://ptc.com/command/view-experience`, that’d open View if installed else redirect to app store to install View.

Here is an example passing foo=baz and bar=blue url params to experience:

https://view.vuforia.com/command/view-experience?url=https%3A%2F%2Feplan-dev.es.thingworx.com%2FExperienceService%2Fcontent%2Fprojects%2Fariotapps-glr%2Findex.html%3Ffoo%3Dbaz%26bar%3Dblue

Please, let me know if you have further quesitons. Thanks

Top Tags