Giter Club home page Giter Club logo

asreviews's Introduction

ASReviews

A small helper to fetch reviews for iOS/Mac OS X Apps from the App Store.

Features

  • Fetch reviews for an iOS/Mac App
  • Calculate average rating based on fetched reviews
  • Filter positive/negative/neutral reviews

TODOs

  • Implement caching
  • Implement method to fetch all available pages at once

Usage

A sample project is included, but in case you want to start right away, add the following files from the sample project to your project:

  • ASReviews.h/.m
  • Review.h/.m

Fetch reviews from a specific page

This sample will fetch the 50 latest reviews for the Facebook iOS App from the US App Store

ASReviews *asr = [ASReviews instance];
[asr setAppId:@"284882215"];
[asr setCountryIdentifier:@"us"];

[asr fetchReviewsFromPage:1 onComplete:^(NSArray *reviews, int page) {
    NSLog(@"Reviews: %@", reviews);
} onError:^(NSError *error, int page) {
    NSLog(@"Failed to fetch reviews on page %i: %@", page, error.description);
}];

Fetch all available reviews at once

This sample will fetch all available reviews for the Facebook iOS App from the US App Store

ASReviews *asr = [ASReviews instance];
[asr setAppId:@"284882215"];
[asr setCountryIdentifier:@"us"];

[asr fetchAllReviews:^(NSArray *reviews, int lastFetchedPage) {
    NSLog(@"Average rating: %.2f based on %i reviews", [asr averageRatingForVersion:nil], reviews.count);
}];

Filter reviews

This sample will fetch the latest 50 reviews and filters out negative reviews (1 and 2 star reviews)

ASReviews *asr = [ASReviews instance];
[asr setAppId:@"284882215"];
[asr setCountryIdentifier:@"us"];

[asr fetchReviewsFromPage:1 onComplete:^(NSArray *reviews, int page) {
    NSLog(@"Negative reviews: %@", [asr negativeReviews]);
    //NSLog(@"Positive reviews: %@", [asr positiveReviews]);
    //NSLog(@"Neutral reviews: %@", [asr neutralReviews]);
} onError:^(NSError *error, int page) {
    NSLog(@"Failed to fetch reviews on page %i: %@", page, error.description);
}];

Check if a review is positive, negative or neutral

If you're displaying reviews in a UITableView you might want to adjust the UITableViewCells appearance accordingly. Each review object has 3 methods to check wether it is a positive, negative or neutral review.

ASReviews *asr = [ASReviews instance];
[asr setAppId:@"284882215"];
[asr setCountryIdentifier:@"us"];

[asr fetchReviewsFromPage:1 onComplete:^(NSArray *reviews, int page) {
    for(Review *review in reviews) {
        if([review isPositive]) NSLog(@"Positive review");
        
        if([review isNegative]) NSLog(@"Negative review");
        
        if([review isNeutral]) NSLog(@"Neutral review");
    }
} onError:^(NSError *error, int page) {
    NSLog(@"Failed to fetch reviews on page %i: %@", page, error.description);
}];

License

This code is licensed under my very own and special "Do whatever you want with it" license.

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.