Latest 1.0.4
Homepage https://github.com/kubatruhlar/AFNetworking-RetryPolicy
License MIT
Platforms ios 7.0, osx 10.9, requires ARC
Dependencies AFNetworking, ObjcAssociatedObjectHelpers
Frameworks Foundation

AFNetworking+RetryPolicy

Travis
Version
Platform
Documentation
Join the chat at https://gitter.im/AFNetworking-RetryPolicy/
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.

Features

  • [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.

Usage

Example

  • Simple GET request with AFNetworking+RetryPolicy could look like this:
    AFHTTPSessionManager *manager = [AFHTTPSessionManager new];
    [manager GET:@"foo" parameters: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]];

Log

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

Requirements

  • AFNetworking 3.0 or later (However old versions are available at the other branches)
  • Target iOS 7 or later
  • Target OS X 10.9 or later
  • Xcode 7 or later

Old versions

For AFNetworking 1 support*

  • use branch afn1-support.
  • Installing through CocoaPods with pod 'AFNetworking+RetryPolicy', git: 'https://github.com/kubatruhlar/AFNetworking-RetryPolicy.git' , branch: 'afn1-support'

*Will not be updated anymore.

For AFNetworking 2 support*

  • use branch afn2-support.
  • Installing through CocoaPods with pod 'AFNetworking+RetryPolicy', git: 'https://github.com/kubatruhlar/AFNetworking-RetryPolicy.git' , branch: 'afn2-support'

*Will not be updated anymore.

Author and credit

License

  • Like :+1: AFNetworking, this category is published under the MIT License. See LICENSE.md for details.

Latest podspec

{
    "name": "AFNetworking+RetryPolicy",
    "version": "1.0.4",
    "summary": "AFNetworking+RetryPolicy is an objective-c category that adds the ability to set the retry logic for requests made with AFNetworking.",
    "description": "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.",
    "homepage": "https://github.com/kubatruhlar/AFNetworking-RetryPolicy",
    "screenshots": "https://raw.githubusercontent.com/kubatruhlar/AFNetworking-RetryPolicy/master/Images/logo.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "authors": "Jakub Truhlar",
    "social_media_url": "http://kubatruhlar.cz",
    "platforms": {
        "ios": "7.0",
        "osx": "10.9"
    },
    "source": {
        "git": "https://github.com/kubatruhlar/AFNetworking-RetryPolicy.git",
        "tag": "1.0.4"
    },
    "source_files": "AFNetworking+RetryPolicy/*.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [
            "~> 3.0"
        ],
        "ObjcAssociatedObjectHelpers": [
            "2.0.1"
        ]
    }
}

Pin It on Pinterest

Share This