I am having a weird bug where the background service in iOS doesn't start the first time I hit the home button.
My code is simple:
//-- app.js
Ti.App.addEventListener('paused', function(event)
{
Ti.API.info('paused');
var bgService = Ti.App.iOS.registerBackgroundService({
url: 'includes/services/ios_bgservice.js'
});
});
//-- ios_bgservice.js
Ti.API.warn('bg logout process has begun for iOS');
My process is:
paused
". I should see "paused [new line] bg logout process has begun for iOS
"If I launch the app again via the dashboard (Do not recompile), then hit the home button, the console shows paused [new line] bg logout process has begun for iOS
This had to break somewhere around this year because I know at one point it was working. I have also confirmed the behavior is the same when tested on the device.
Additional Info
Well, it's pretty simple. You cannot register a web service after your application has paused.
You simply write the following lines and your service will automatically be triggered, when your application goes in pause state
var service = null;
if(service != null){
service = Ti.App.iOS.registerBackgroundService({
url: 'includes/services/ios_bgservice.js'
});
}
Hope this Helps !!!