I have created an iPhone application using phoneGap and i have implemented the Websync functionality using javascript, all functionality are working fine, but my problem is that When Iphone goes to sleep mode than the app is still open and when you wakeup the phone websync doesnt work anymore.
Asked
Active
Viewed 170 times
2 Answers
0
Generally speaking iOS apps are not allowed to maintain a permanent connections in the background.
Keep in mind the following about inactive apps:
Inactive The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state.

Javier Quevedo
- 2,066
- 1
- 17
- 27
0
iOS (and other mobile devices) don't allow JavaScript to run in the background when the device is sleeping. Battery life would suffer tremendously if it did.
However, WebSync 4 should automatically re-connect to the server after waking up. If you are using WebSync 3, you have to set a flag (stayConnected) to get the same behaviour:
client.connect({ stayConnected: true }); // WebSync 3 only

Anton
- 4,554
- 2
- 37
- 60