Skip to main content
7-Bedrock
October 28, 2024
Question

$viewContentLoaded not getting called in Vuphoria Studio

  • October 28, 2024
  • 3 replies
  • 760 views

I want to call a function sessionTracking as below on $viewContentLoaded and get the cookie values,but my function is not getting called on $viewContentLoaded and the console statements are not getting executed, Can you please let me know how can this be achieved using Vuphoria Studio?Is there $viewContentLoaded  in Vuphoria Studio If not what is the alternate way to do it? Please suggest.

 

$scope.getCookie = function(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

$scope.sessionTracking = function(){
let xsrfToken = $scope.getCookie('XSRF-TOKEN');
console.log("xsrfToken"+xsrfToken);
let studioSessionId = $scope.getCookie('studio-sessionid');
console.log("studioSessionId"+studioSessionId);
let studioES = $scope.getCookie('studio_ES');
console.log("studioES"+studioES);
twx.app.fn.triggerDataService('ARSession.ARSessionTracking', {
xsrfToken,studioSessionId,studioES
})
}

 

 

 

3 replies

17-Peridot
December 2, 2024

Hello @SS_11298241 ,
I am not sure what information you are trying to access.  I believe there are session variables but I am not sure if that is what you describe as a Cookie?

What is your target environment? Are you trying to extract cookie information from the Vuforia View application?

 

Regards,

pehowe

21-Topaz I
December 12, 2024

Hi @SS_11298241 ,

I am not sure if that will be passed through the javascript env in Vuforia angular enviroment. So we tried in the past to summarize that possible events in the post : List of Vuforia Studio events which we could be used as listener by javaScript/angular.js

 

is then the loading of the view event ok?

.Possibly you can use the event after entering in  a view in studio (e.g. Home ...):

 

...
$scope.$on('$ionicView.afterEnter', function() {$scope.populateModelList();
 });
...
// or before the view is entered
$scope.$on('$ionicView.beforeEnter', function() {
console.warn('---- ON: BEFORE ENTER VIEW ----')
//...
})

 

17-Peridot
February 20, 2025

Hello @SS_11298241  ,

It appears that your question has been answered.  For the benefit of other Community Members who may have the same question, it would be great if you could designate it as the Accepted Solution.

In the event that this response did not answer your question, please post your current status so that we can continue to support.

Thanks for using the PTC Community!

Regards,

pehowe