Create Developer App Related Logic

During development, you can detect if your app is running in the NativeScript developer app and create logic to work around some of its limitations. For example, when your app is running in the Developer app, you might show or log warnings when you try to call methods of unsupported plugins or you can point your app to consume resources from an alternative location.

Developer App JavaScript API

AppBuilder provides the boolean isInCompanionApp global variable. This property has the following values.

  • true: Indicates that the app is running in the Developer app.
  • false: Indicates that the app is not running in the Developer app.

Developer App JavaScript API Examples

/* 
* Detects if the app is running in the Developer app.
* If running in the Developer App, shows a simple warning alert.
* Continues executing the logic of your app.
*/

if (typeof(isInCompanionApp) === true) {
    alert("Your app is running in the Developer app. Test results might be inaccurate.");  
};
/*
* Sets a configuration based on whether the app is running in the Developer app.
*/

function setConfig() {
  if (typeof(isInCompanionApp) === true) {
     apiUrl = "http://localhost:1234/api/myapp";
     }
  else {
     apiUrl = "https://myapp.com/api/myapp";
    }
};

Next Steps

Run Your App in the NativeScript developer app.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.