gpt4 book ai didi

ios - 在 iOS objective-c 中从前台过渡到后台后继续调用 Web 服务

转载 作者:行者123 更新时间:2023-11-28 18:09:26 24 4
gpt4 key购买 nike

假设我在应用程序处于前台时调用网络服务。现在,如果用户将应用程序发送到后台,那么我如何确保此 Web 服务调用继续在后台执行。

这是我在我的应用中使用的代码。

Login* login = [[Login alloc]init];
[login initiateSignInProcess];

initiateSignInProcess has 4 web service calls. they are normal functions. I am using AFNetworking.

如果任何服务失败,我会在网络代码的失败 block 中延迟再次调用它,如下所示:-

failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
[self performSelector:@selector(getUserId) withObject:nil afterDelay:5];
}

现在我想知道如果用户将应用程序发送到后台,那么代码将如何执行?它会在bakcground中调用这个函数直到成功吗?

最佳答案

最好使用后台进程进行抓取。这是解决方案的好教程 [http://code.tutsplus.com/tutorials/ios-7-sdk-working-with-background-fetch--mobile-20520

关于ios - 在 iOS objective-c 中从前台过渡到后台后继续调用 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33140427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com