IOS - 在重新建立连接时对要发送的请求进行排队的最佳方法 [英] IOS - best way to queue requests to be sent when connection is reestablished
问题描述
在我的IOS应用程序中,我在我的应用程序中进行了应用程序内购买,我需要将收据发送到我的Web服务,以便将高级内容分配给用户帐户。即使在应用程序内购买完成后连接丢失,我也要求它可靠。
in my IOS application I have an in-app purchase in my app and I need to send receipt to my web service to assign premium content to a user account. I need this to be reliable even when the connection is lost right after the in-app purchase completes.
是否有任何可以接受请求并执行的实体库当重新建立连接时?
Are there any solid libraries out there that can take a request and execute it when connection is reestablished?
推荐答案
我肯定会推荐 AFNetworking ,一个非常精心制作的网络库,包含NSURLConnection。
I would definitely recommend AFNetworking, a very well-made networking library which wraps NSURLConnection.
为了您的目的使用它需要利用中建议的 AFHTTPClient
的可访问性内置功能其他答案。
In order to use it for your purpose you need to take advantage of the reachability build-in features of AFHTTPClient
as suggested in this other answer.
基本上,只要网络的可达性状态发生变化,你就可以使用 setReachabilityStatusChangeBlock来执行和任意阻止:
AFHTTPClient
的方法。
Basically you can execute and arbitrary block whenever the reachability status of the network changes using the setReachabilityStatusChangeBlock:
method of AFHTTPClient
.
请记住链接并导入 Syste mConfiguration
框架,否则它将无效。
Just remember to link and import the SystemConfiguration
framework, otherwise it won't work.
这篇关于IOS - 在重新建立连接时对要发送的请求进行排队的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!