简体   繁体   中英

Websync breaks when Iphone goes to sleep

我已经使用phoneGap创建了一个iPhone应用程序,并且已经使用javascript实现了Websync功能,所有功能都可以正常工作,但是我的问题是,当Iphone进入睡眠模式时,该应用程序仍处于打开状态,并且当您唤醒电话时,Websync无法正常工作不再。

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:

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.

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM