[ALOY-1732] Add ability to run in the background without UI

GitHub Issuen/a
TypeNew Feature
Resolution Date2020-08-12T14:28:28.000+0000
Affected Version/sn/a
Fix Version/sCLI Release 8.1.0
Labelsalloy, android, background, ios
ReporterJoshua Quick
AssigneeJoshua Quick


*Summary:* We plan on adding a new "tiapp.xml" property "run-in-background", when set true, will allow the "app.js" to be executed while the app is in the background and is unable to host UI. This means we have to defer root window creation until the app is ready to host UI. On Android, we also need to support recreation of the root window when user backs out of the app and re-launches it. See Titanium SDK ticket [TIMOB-27896] for details. *To-Do:* The "app.js" generated by Alloy needs to be changed to the following...
// Open root window if a new UI session has started. Can happen more than once in app's lifetime.
// Event can only be fired if "tiapp.xml" property "run-in-background" is set true.
Ti.UI.addEventListener('sessionbegin', function () {

// Open the root window immediately if an active UI session exists.
// Note: The Ti.UI.hasSession property was added as of Titanium 9.1.0.
if ((typeof Ti.UI.hasSession === 'undefined') || Ti.UI.hasSession) {
*Note:* We need to release this Alloy change via CLI 8.1.0 before we release Titanium 9.1.0. The new Titanium backgrounding feature won't work correctly on Alloy without it. The plan is to have the Titanium 9.1.0 build system check that CLI 8.1.0 is installed when the backgrounding feature is enabled in the "tiapp.xml" or else we'll trigger a build failure.


  1. Joshua Quick 2020-06-03 PR (master): https://github.com/appcelerator/alloy/pull/959
  2. Ewan Harris 2020-07-20 Test steps: This isn't really testable until TIMOB-27896 is merged, but for now just testing that apps launch fine with this change will do
  3. Samir Mohammed 2020-08-12 Closing ticket, fix verified in CLI version 8.1.0-master.10, app launches just fine.

JSON Source