Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

stop background services in titanium studio?

$
0
0

hi, I am initiating services in app.js, I want to stop the services in active window by using switch. how to do this?
my code is

Ti.App.addEventListener('pause', function(e) {
        // register a background service. this JS will run when the app is backgrounded
        //if switch is ON start the back ground services, when app is pause
 
        if (Ti.App.Properties.getString('getLocation') == 'YES') {
        if(service === null)
        {
            service = Ti.App.iOS.registerBackgroundService({
                url : '/mainWindows/bg.js'
            });
        }
        // else
        // {
            // service.stop();
            // service.unregister();
        // }
        }
        else
        {
            timer = Ti.App.Properties.getString('timerValue');
            clearInterval(timer);
            service.stop();
            service.unregister();
        }
 
    });
bg.js is empty file, In other .js file called geoTrace.js I have a switch, if I off the switch the services could be off.

Please do help for this thanks in advance.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>