1

I am working on an application where I need to notifiy the user hourly for a set period of time. I am making this application in Titanium, so I can easily use the code for both Android and iOS.

For Android I am using this:

var intent = Titanium.Android.createServiceIntent({
            url : 'alarmservice.js'
        });
        intent.putExtra('interval', MINUTE * 60);
        Titanium.Android.startService(intent);

Which works fine, however this doesn't work for iOS. And if it works, the background task will keep running for a couple of minutes until it gets terminated. Is there any way to achieve that a task keeps running, like an alarm clock?

If this is not possible in Titanium itself, would it be possible in native code?

Any help is appreciated!

Jef
  • 791
  • 1
  • 18
  • 36

1 Answers1

1

It's not possible on iOS. Not because of Titanium, but because iOS does not allow background service like Android does. If I remember correctly, the max time iOS allows an app to run in background is 10 minutes.

What you could do is utilize the notifications to set up at an interval time as suggested here: Schedule Tasks to execute methods in iOS

Community
  • 1
  • 1
developer82
  • 13,237
  • 21
  • 88
  • 153
  • Thanks for the information, this is not what I was hoping to hear. So there is no way to automatically notify the user every hour without the user opening the application? – Jef Feb 12 '14 at 12:01
  • @Jef it depends on how you work it out I guess. If you use the local notifications schedule the phone can notify the user a message of your choice and when clicked it will open your app. – developer82 Feb 12 '14 at 13:30