Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Remind review in iPhone apps

, 12 Dec 2013
Rate this:
Please Sign up or sign in to vote.
How to remind review in iPhone App

Introduction

In iPhone apps, we often need to remind the user to review/rate the app in iTunes. This sample code will demo a simple solution.

CloudReview.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface CloudReview : NSObject {
    int m_appleID;
}
+(CloudReview*)sharedReview;
-(void) reviewFor:(int)appleID;
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
@end
CloudReview.m
#import "CloudReview.h"

@implementation CloudReview
static CloudReview* _sharedReview = nil;
+(CloudReview*)sharedReview
{
    @synchronized([CloudReview class])
    {
        if (!_sharedReview)
            [[self alloc] init];
        
        return _sharedReview;
    }
    
    return nil;
}
+(id)alloc
{
    @synchronized([CloudReview class])
    {
        NSAssert(_sharedReview == nil, 
            @"Attempted to allocate a second instance of a singleton.");
        _sharedReview = [super alloc];
        return _sharedReview;
    }
    
    return nil;
}
-(void)reviewFor:(int)appleID
{
    m_appleID = appleID;
    BOOL neverRate = [[NSUserDefaults standardUserDefaults] boolForKey:@"neverRate"];
    if(neverRate != YES) {
        //Show alert here
        UIAlertView *alert;
        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"rate_title",@"Rate My Appication")
                     message:NSLocalizedString(@"rate_main",@"Please Rate my Application")
                     delegate: self
                     cancelButtonTitle:NSLocalizedString(@"rate_cancel",@"Cancel")
                     otherButtonTitles: NSLocalizedString(@"rate_now",@"Rate Now"),
                 NSLocalizedString(@"rate_never",@"Never Rate"), nil];
        [alert show];
        [alert release];
    }
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    // Never Review Button
    if (buttonIndex == 2)
    {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"neverRate"];
    }
    // Review Button
    else if (buttonIndex == 1)
    {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"neverRate"];
        NSString *str = [NSString stringWithFormat:
                @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore" + 
                @".woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",
                m_appleID ]; 
        NSLog(str);
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }
}
@end 

CloudReview was declared in my library, I always use it in my app. The solution pops a UIAlertView to remind the user and it will save the result in NSUserDefaults.

How to use

[[CloudReview sharedReview]reviewFor:395519376];

Just use this code. Maybe you will ask me, how do we get an AppleID?

In this link, we can see the number 428839866, which is the Apple ID. Or we can get it from iTunes Connect.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Cloud Hsu
Architect LPI
Taiwan Taiwan
CloudBox cross-platform framework. (iOS+ Android)
Github: cloudhsu
My APP:
1. Super Baby Pig (iOS+Android)
2. God Lotto (iOS+Android)
2. Ninja Darts (iOS)
3. Fight Bingo (iOS)
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
Questionerror Pinmembercruiserpaule23-Jan-13 4:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 12 Dec 2013
Article Copyright 2011 by Cloud Hsu
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid