Nice category that adds the ability to set the retry interval, retry count and progressiveness.
If a request timed out, you usually have to call that request again by yourself. AFNetworking+RetryPolicy is an objective-c category that adds the ability to set the retry logic for requests made with AFNetworking.
pod 'AFNetworking+RetryPolicy'
#import "AFHTTPSessionManager+RetryPolicy.h"
directive.Want to try it first? Use
pod try AFNetworking+RetryPolicy
command.
GET
request with AFNetworking+RetryPolicy could look like this: AFHTTPSessionManager *manager = [AFHTTPSessionManager new];
[manager GET:@"foo" parameters:nil headers:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
NSLog(@"%@", responseObject);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"%@", error.localizedDescription);
} retryCount:5 retryInterval:2.0 progressive:false fatalStatusCodes:@[@401, @403]];
AFHTTPSessionManager
’s retryPolicyLogMessagesEnabled
property to true
. Disabled by default.
afn2-support
.pod 'AFNetworking+RetryPolicy', git: 'https://github.com/kubatruhlar/AFNetworking-RetryPolicy.git' , branch: 'afn2-support'
*Will not be updated anymore.
afn1-support
.pod 'AFNetworking+RetryPolicy', git: 'https://github.com/kubatruhlar/AFNetworking-RetryPolicy.git' , branch: 'afn1-support'
*Will not be updated anymore.