IOS - best way to queue requests to be sent when connection is reestablished

落爺英雄遲暮 提交于 2019-12-20 04:51:14

问题


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?


回答1:


I would definitely recommend AFNetworking, a very well-made networking library which wraps NSURLConnection.

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.

Basically you can execute and arbitrary block whenever the reachability status of the network changes using the setReachabilityStatusChangeBlock: method of AFHTTPClient.

Just remember to link and import the SystemConfiguration framework, otherwise it won't work.



来源:https://stackoverflow.com/questions/13811022/ios-best-way-to-queue-requests-to-be-sent-when-connection-is-reestablished

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!