Awesome Open Source
Awesome Open Source


Travis Version Platform Documentation Join the chat at License

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.


  • [x] retryCount - How many times to try.
  • [x] retryInterval - Time interval between attempts in seconds.
  • [x] progressive - Next attempt will always take more time than the previous one. (Uses Exponentiation)
  • [x] fatalStatusCodes - These will trigger failure block immediately when received and ends current retry.

Getting started

  • Installing through CocoaPods with pod 'AFNetworking+RetryPolicy'
  • Use #import "AFHTTPSessionManager+RetryPolicy.h" directive.

Want to try it first? Use pod try AFNetworking+RetryPolicy command.



  • Simple 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]];


  • Enable to see what is happening by setting the AFHTTPSessionManager’s retryPolicyLogMessagesEnabled property to true. Disabled by default.


  • AFNetworking 4.0 or later
  • Target iOS 9 or later
  • Target OS X/macOS 10.10 or later
  • Xcode 11 or later

Old versions

For AFNetworking 3 support

  • use version 1.x.

For AFNetworking 2 support*

  • use branch afn2-support.
  • Installing through CocoaPods with pod 'AFNetworking+RetryPolicy', git: '' , branch: 'afn2-support'

*Will not be updated anymore.

For AFNetworking 1 support*

  • use branch afn1-support.
  • Installing through CocoaPods with pod 'AFNetworking+RetryPolicy', git: '' , branch: 'afn1-support'

*Will not be updated anymore.

Author and credit


  • Like 👍 AFNetworking, this category is published under the MIT License. See for details.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Objective C (110,716
Cocoapods (1,973
Retry (251
Interval (215
Related Projects