Giter Club home page Giter Club logo

afnetworking-retrypolicy's Introduction

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

  • retryCount - How many times to try.
  • retryInterval - Time interval between attempts in seconds.
  • progressive - Next attempt will always take more time than the previous one. (Uses Exponentiation)
  • 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 👍 AFNetworking, this category is published under the MIT License. See LICENSE.md for details.

afnetworking-retrypolicy's People

Contributors

kubatruhlar avatar marslin1220 avatar

Watchers

James Cloos avatar FrokingMonkey avatar SimbaGong avatar paopaotang avatar miantiaomao avatar alihaiseyao avatar  avatar  avatar Jasper avatar Tofu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.