1

I am building an mobile app ( RSS reader ) for Android with Sencha touch and PhoneGap. I have created some sort of background service that checks every 12 hours for new posts and update the app. When there is a new post a notification is shown up ( http://developer.android.com/guide/topics/ui/notifiers/notifications.html )

I am using window.setInterval() for this. This seems like a dirty way to do it, but it works.

Whats your opinion about this and is there a better way to get the job done?

Nag
  • 1,438
  • 1
  • 11
  • 39
Melvin
  • 3,421
  • 2
  • 37
  • 41
  • You may want to read through this... http://stackoverflow.com/questions/1243066/does-android-support-near-real-time-push-notification – ballmw May 04 '11 at 16:50

1 Answers1

1

The only other way, in JS, to do it would be a long poll with an XHR request. The notifications can then be pushed when they show up instead of every 12 hrs. However this probably isn't a great solution as it will tie up server resources and require a constant connection.

Because you are also using PhoneGap, you could write a plugin for Android that will implement a JS object with the ability to register callbacks for and call them at a particular time. Or implement the API that @ballmw suggested.

In the end, setTimeout/setInterval is probably fine if it works properly.

mistagrooves
  • 2,337
  • 15
  • 16