how i use backgroundService in iPhone with time interval?

You must Login before you can answer or comment on any questions.

Hi, i Think this is very poor question. But, I don't understand 1. how i use this. 2. which type this working in device? please any one help me? Thanks in advance..!

1 Answer

Accepted Answer

hi Mrityunjay,

have you checked kitchensink demo..?

— answered 1 year ago by Mitul Bhalia
answer permalink
3 Comments
  • https://github.com/appcelerator/KitchenSink/blob/master/Resources/bg.js

    — commented 1 year ago by Mitul Bhalia

  • in app.js

    function isiOS4Plus()
    {
        // add iphone specific tests
        if (Titanium.Platform.name == 'iPhone OS')
        {
            var version = Titanium.Platform.version.split(".");
            var major = parseInt(version[0],10);
     
            // can only test this support on a 3.2+ device
            if (major >= 4)
            {
                return true;
            }
        }
        return false;
    }
     
    if (isiOS4Plus())
    {
    // register a background service. this JS will run when the app is backgrounded
    var service = Ti.App.iOS.registerBackgroundService({url:'bg.js'});
     
    Ti.API.info("registered background service = "+service);
     
    // listen for a local notification event
    Ti.App.iOS.addEventListener('notification',function(e)
    {
    Ti.API.info("local notification received: "+JSON.stringify(e));
    });
     
    // fired when an app resumes for suspension
    Ti.App.addEventListener('resume',function(e){
    Ti.API.info("app is resuming from the background");
    });
    Ti.App.addEventListener('resumed',function(e){
    Ti.API.info("app has resumed from the background");
    });
     
    Ti.App.addEventListener('pause',function(e){
    Ti.API.info("app was paused from the foreground");
    });
    }

    — commented 1 year ago by Mitul Bhalia

  • yes, I check it .... this is very helpful for me Thanx...

    — commented 1 year ago by Mritunjay Singh

Your Answer

Think you can help? Login to answer this question!