8 Replies Latest reply on Jan 18, 2018 3:37 PM by sasathe RSS
    sasathe Newbie

    Can I create mobile app using Thingworx?

    Is it possible to create mobile app using Thingworx? If yes please share me any related document or link or video.

    Thanks,

    Sachin

      • Re: Can I create mobile app using Thingworx?
        Ankit Gupta Ninja

        Hi Sachin Sathe,

        Are you looking to send data from mobile to ThingWorx server? If yes PTC ThingWorx have IOS SDK and Android SDK.

        ThingWorx is webservice so you can access the pages via your mobile browser too. But you might want to create separate Mashups for mobile view for better experience.

        • Re: Can I create mobile app using Thingworx?
          carlesc Heavyweight Champ

          Hi Sachin,

           

          Currently TW has a Mobile App development platform it's name it's Vuforia, but it maybe too much AR related.

           

          We had successfully build before Mobile Apps before above ThingWorx REST API using HTML5 Ionic framework ( or you may use any other you want )

           

          Or as Ankit stated if you want to build native Apps you can use the SDKs.

           

          Carles.

            • Re: Can I create mobile app using Thingworx?
              ekoraichi-2 Newbie

              Hi Carles,

              Actually I took your advice and i'm building an mobile app using Ionic 2, but my question is how can I implements a login authentication based on thingworx users. thanks

                • Re: Can I create mobile app using Thingworx?
                  carlesc Heavyweight Champ

                  This is our Login full code, hope it helps:

                   

                  
                  this.login = function(name, pw) 
                  {
                  
                  
                      return $q(function(resolve, reject) 
                  {
                  var data = JSON.stringify({ "context": "appHandMeter" });
                  
                  
                  var xhr = new XMLHttpRequest();
                  
                  
                  if (WITH_CREDENTIALS!=undefined) {
                  xhr.withCredentials = WITH_CREDENTIALS;
                  }
                  xhr.addEventListener("readystatechange", function () 
                  {
                    if (this.readyState === 4) 
                  {
                  if (this.status==200) {
                     //saving result key
                     var Data = JSON.parse(xhr.responseText);
                     //saving token info
                     var returnToken = (Data.rows[0].result); 
                         
                  var xhrlogout = new XMLHttpRequest();
                  if (WITH_CREDENTIALS!=undefined) {
                  xhrlogout.withCredentials = WITH_CREDENTIALS;
                  }
                  var logOut = REST_API.LOCATION + REST_API.LOGOUT;
                  
                  
                  xhrlogout.addEventListener("readystatechange", function () 
                  {
                  if (this.readyState === 4) 
                  {
                  if (this.status==200) 
                  {
                     //calling again the logout to clean up the session cookie
                  var xhrlogout2 = new XMLHttpRequest();
                  if (WITH_CREDENTIALS!=undefined) {
                  xhrlogout2.withCredentials = WITH_CREDENTIALS;
                  }
                  var logOut = REST_API.LOCATION + REST_API.LOGOUT;
                  
                  
                  xhrlogout2.addEventListener("readystatechange", function () {
                  if (this.readyState === 4) {
                  resolve(returnToken);
                  }
                  });
                  
                  xhrlogout2.open("POST", logOut ,true);
                  
                  xhrlogout2.setRequestHeader("Content-Type", "application/json");
                  xhrlogout2.setRequestHeader("Accept", "application/json");
                  xhrlogout2.timeout = REST_API.TIMEOUT;
                  xhrlogout2.ontimeout= function(){
                  resolve(returnToken);
                  }
                  xhrlogout2.send();    
                     
                  }
                  else
                  {
                  resolve(returnToken);
                  }
                  }
                  });
                  
                  xhrlogout.open("POST", logOut ,true);
                  
                  //setting up headers
                  xhrlogout.setRequestHeader("Content-Type", "application/json");
                  xhrlogout.setRequestHeader("Accept", "application/json");
                  xhrlogout.timeout = REST_API.TIMEOUT;
                  xhrlogout.ontimeout= function(){
                  resolve(returnToken);
                  }
                  //sending the post request
                  xhrlogout.send();
                  /************************/
                  
                     
                  } else 
                  {
                  reject(this.status);
                  }
                  }
                  });
                  
                  
                  
                  //Converting the user and password to base 64
                  var encodedData = window.btoa(name + ":" + pw);
                  //Construction of the login url 
                  var loginUrl = REST_API.LOCATION + REST_API.LOGIN;
                  
                  
                  xhr.open("POST", loginUrl ,true);
                  
                  
                  
                  
                  //setting up headers
                  xhr.setRequestHeader("Content-Type", "application/json");
                  xhr.setRequestHeader("Accept", "application/json");
                  xhr.setRequestHeader("Authorization", "Basic " + encodedData);
                  xhr.setRequestHeader("Cache-Control", "no-cache");
                  //sending the post request
                  xhr.timeout = REST_API.TIMEOUT;
                  xhr.ontimeout= function(){
                  reject();
                  }
                  xhr.send(data);
                  
                  });
                  }