3

Can I get a phonegap application running on iOS 4 to have a background service when it's not the active app (e.g. check a url every hour and alert the user if there have been any changes)?

And if so, how?

Omer
  • 582
  • 3
  • 14
  • 24

3 Answers3

2

Yes, you can do that, but Apple will probably disallow it. Background running is bound to VERY specific rules. For this kind of stuff Apple invented Push Notifications (from server).

You can read the developer documentation about that.

Wim Haanstra
  • 5,918
  • 5
  • 41
  • 57
1

The best way to achieve this would be to create a plugin for PhoneGap, which runs natively on the phone. PhoneGap recommends that any heavy lifting be done by native code.

Check out the IOS documentation for background tasks, it should tell you what is allowed, and what is not.

http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

paul
  • 11
  • 1
0

Why don't you use onPause and onResume events. They are quite helpful.

Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
  • For example you can do document.addEventListener("resume", my_function, false); and there is "pause", "online" and "offline" too – Magnus Smith Dec 14 '12 at 16:09
  • @MagnusSmith If I use onPause event does that mean app went to background ? If so can I call a function in that which would run in background ? – GoodSp33d Apr 29 '13 at 12:09
  • I am guessing(!) the event is better described as 'beforepause' and gets run just before your app goes into hibernation. – Magnus Smith Apr 29 '13 at 12:50