Phonegap background service on iOS4?
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 ha开发者_JAVA百科ve been any changes)?
And if so, how?
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.
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
Why don't you use onPause and onResume events. They are quite helpful.
精彩评论