1 Reply Latest reply on Jun 26, 2017 10:04 AM by kerrishotts

    Help Using Test/Live Web Service URLs


      I'm using Phonegap Build online for testing devices installed app and Chrome/Ripple for testing my app locally. Currently using the following to set the global web service reference pointer so I don't have to keep switching this string when deploying to phonegap. Now I would like to add a third "test.domain.com" so I can test the app to a test web service database so I can do test transaction before making my app live. Looking for some trick or tips on dealing with test environments and live setting variables in a phonegap app. Any pointers? In this example I used "hostname" to decipher environment.


      Here is the code I include on all my html as global.js <script type="text/javascript" src="js/global.js"></script> as global variables in the html5


      if (window.location.hostname == "")   //Dev


          localStorage.setItem("webServiceUrl", '');   


      else //Prod


          localStorage.setItem("webServiceUrl", 'https://domain.com/myapp/mobile.asmx/');


        • 1. Re: Help Using Test/Live Web Service URLs
          kerrishotts Adobe Employee

          If you were using the CLI, there'd be many options available, but a pure PGB option... hmm.


          Simplest option might be to have a settings screen where you can toggle test/prod status. I built an app for a client that did that -- the option to change the setting was buried and had to be enabled a certain way, but it worked. Requires manual intervention on your part (not automatically determined), but should work in a pinch. (In the app we built, the setting was saved locally, so you only had to do it once.)