简体   繁体   English

iPhone屏幕锁上的Web服务呼叫失败

[英]Web Service Call Fails on iPhone Screen Lock

If the iPhone screen locked automatically or annually while I call any Web Service then the connection breaks and its throw unable to connect server message. 如果在我致电任何Web服务时iPhone屏幕自动锁定或每年一次锁定,则连接中断并且无法连接服务器消息。

Is there any way I can resume the service call or handle screen lock scenario. 有什么办法可以恢复服务呼叫或处理屏幕锁定情况。

Due to this app goes in inconsistent state some time 由于此应用在一段时间内处于不一致状态

When Phone is locked or The App is in background mode. 当手机被锁定或应用处于后台模式时。 you need to call API as a background service. 您需要将API称为后台服务。

Yes, You can handle the screen lock scenario. 是的,您可以处理屏幕锁定方案。

[UIApplication sharedApplication].idleTimerDisabled = YES;

you can set this when you start calling web service and stop by set value to NO when you finished your work. 您可以在开始调用Web服务时进行设置,而在完成工作时将其设置为NO停止。

And if it does not work, then you can put this line in appdelegate's method. 如果不起作用,则可以将此行放入appdelegate的方法中。

- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
       [UIApplication sharedApplication].idleTimerDisabled = YES;
       return YES;
}

which will disable your automatic screen lock for whole app while running. 这将在运行时为整个应用程序禁用自动屏幕锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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