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.
Websync breaks when Iphone goes to sleep
184 Views Asked by Gaurav At
2
There are 2 best solutions below
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
Generally speaking iOS apps are not allowed to maintain a permanent connections in the background.
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
Keep in mind the following about inactive apps: