gpt4 book ai didi

iOS 7+ 应用程序是否可以在应用程序处于非事件状态时通过网络发送数据?

转载 作者:行者123 更新时间:2023-11-29 02:43:32 25 4
gpt4 key购买 nike

iOS 7+、8(最后一个尚未发布,但针对它)。该应用程序。作为用户,我启动应用程序并切换到其他应用程序(邮件、safari 等),让应用程序运行但不是前台应用程序。该应用程序通过互联网与服务器建立 HTTP 连接,并开始定期向服务器发送 GPS 位置数据(以一定间隔)。

当应用程序不在前台时是否可能?我的意思是,是否可以在使用其他应用程序时获取地理位置数据并通过 HTTP POST 定期将其从应用程序发送到服务器?

如果答案是"is",请帮我提供引用资料。我会进一步调查。

最佳答案

是的,你要研究的方法是performFetchWithCompletionHandler:

Implement this method if your app supports the fetch background mode. When an opportunity arises to download data, the system calls this method to give your app a chance to download any data it needs. Your implementation of this method should download the data, prepare that data for use, and call the block in the completionHandler parameter.

When this method is called, your app has up to 30 seconds of wall-clock time to perform the download operation and call the specified completion handler block. In practice, your app should call the completion handler block as soon as possible after downloading the needed data. If you do not call the completion handler in time, your app is terminated. More importantly, the system uses the elapsed time to calculate power usage and data costs for your app’s background downloads. If your app takes a long time to call the completion handler, it may be given fewer future opportunities to fetch data in the future. For more information about supporting background fetch operations, see “App States and Multitasking” in iOS App Programming Guide.

https://developer.apple.com/library/ios/documentation/uikit/reference/uiapplicationdelegate_protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:performFetchWithCompletionHandler :

关于iOS 7+ 应用程序是否可以在应用程序处于非事件状态时通过网络发送数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25431279/

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