Tuesday, October 2, 2012

Rating of app



Prompting a user to provide a rating is straight forward: using the User Defaults system, we’ll record the date of the first launch. When the user crosses an installed-age threshold, we’ll ask for a rating using alert-view and — with their permission — take them right to the app’s page in the Store to enter a rating. To prompt the user for a rating after the app’s been installed for 10 or more days add the following code the viewDidLoad method in its main view controller:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
if (! [defaults objectForKey:@"firstRun"]) {
 [defaults setObject:[NSDate date] forKey:@"firstRun"];
}
 
NSInteger daysSinceInstall = [[NSDate date] timeIntervalSinceDate:[defaults objectForKey:@"firstRun"]] / 86400;
if (daysSinceInstall > 10 && [defaults boolForKey:@"askedForRating"] == NO) {
 [[[UIAlertView alloc] initWithTitle:@"Like This App?" message:@"Please rate it in the App Store!" delegate:self cancelButtonTitle:@"No Thanks" otherButtonTitles:@"Rate It!", nil] show]; 
 [defaults setBool:YES forKey:@"askedForRating"];
}

[[NSUserDefaults standardUserDefaults] synchronize];


To launch the open the app’s page in the App Store when the user taps the “Rate It!” button subscribe to the UIAlertViewDelegate protocol and implement it’s callback method. Add the protocol to the view controller’s header file, e.g.:
@interface RootViewController : UIViewController <UIAlertViewDelegate> {
 // ...
}


Add the callback method to the view controller’s implementation:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
 if (buttonIndex == 1) {
  NSURL *url = [NSURL URLWithString:@"YOUR URL TBD!!!"];
  [[UIApplication sharedApplication] openURL:url];
 }
}
This callback opens the app's page in the App Store by launching its URL. To determine your's app's URL:
  1. Open iTunes on your Mac
  2. Select iTunes Store from the left-panel
  3. Enter your app's name in the Search iTunes Store text field and hit enter
  4. Control-click on your app's icon and select Copy iTunes Store URL
Opening an App Store URL doesn't work in the simulator; so test this on a device.
To know more: http://mobileorchard.com/fighting-back-against-the-app-stores-negative-rating-bias/

No comments:

Post a Comment