Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XmlHttpRequest on Tizen TV exits application

I am currently developping an app for Samsung Tizen and WebOS TVs. For this, I am using Samsung's TOAST and Caph with angular1.

The generated .wgt is working fine on browser and TV Simulator, but on real device, the application exits when an XMLHttpRequest is sent.

Here is the code:

    var url = "grant_type=password&username=" + $scope.logInfos.loginEmail + "&password=" + $scope.logInfos.loginPassword;
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'https://myUrl/token');
    xhr.onreadystatechange = function() {
        xhr.onloadend = function() {
            if (xhr.response) {
                console.log("logged in");
            }
        };
    };
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.send(url);

These lines are launched when the login form is submitted but at this moment the application exits. There are no error message in the console and no trace of the xhr in the network tab.

I tried changing HTTPS to HTTP in case this was the problem but it did nothing.

Could you please help?

like image 681
Kerhael Avatar asked Dec 24 '22 23:12

Kerhael


2 Answers

Don't forget to add privilege and allow domains in your config.xml

<access origin="*" subdomains="true"></access>
<tizen:privilege name="http://tizen.org/privilege/internet"/>
like image 122
Iqbal hossain Avatar answered Dec 28 '22 08:12

Iqbal hossain


After searching, it appears TOAST deleted the following line:

    <access origin='*' subdomains='true'/>

All I had to do to make my app work was adding this line again into config.xml file. Problem solved!

like image 44
Kerhael Avatar answered Dec 28 '22 08:12

Kerhael