Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

pull app store id from the info.plist #28

Open
wants to merge 3 commits into from

4 participants

@duanefields

This change pulls the appstore id from the info.plist, using the key "AppStoreId", rather than requiring a source change to the Appirater.h file. This makes reusing the code much easier.

Duane Fields added some commits
@Merlineus

Very useful addition. Thanks!

@mysticboy59

Thanks from me as well. Very useful addition. Quick approach.

@g-mark g-mark commented on the diff
Appirater.m
@@ -339,7 +346,7 @@ + (void)rateApp {
NSLog(@"APPIRATER NOTE: iTunes App Store is not supported on the iOS simulator. Unable to open App Store page.");
#else
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
- NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]];
+ NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", [self appStoreAppID]]];
@g-mark
g-mark added a note

Should be:
NSString reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[self appStoreAppID]];
since [self appStoreAppID] returns an NSString
, and not an int.

Then you don't need the string format, the code was written using the constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 26, 2011
  1. appstore id is pulled from the info.plist, rather than requiring a so…

    Duane Fields authored
    …urce change
  2. oops, typo

    Duane Fields authored
  3. fixed a typo

    Duane Fields authored
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 6 deletions.
  1. +0 −5 Appirater.h
  2. +8 −1 Appirater.m
View
5 Appirater.h
@@ -44,11 +44,6 @@ extern NSString *const kAppiraterRatedCurrentVersion;
extern NSString *const kAppiraterDeclinedToRate;
/*
- Place your Apple generated software id here.
- */
-#define APPIRATER_APP_ID 301377083
-
-/*
Your app's name.
*/
#define APPIRATER_APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]
View
9 Appirater.m
@@ -45,6 +45,7 @@
NSString *const kAppiraterRatedCurrentVersion = @"kAppiraterRatedCurrentVersion";
NSString *const kAppiraterDeclinedToRate = @"kAppiraterDeclinedToRate";
NSString *const kAppiraterReminderRequestDate = @"kAppiraterReminderRequestDate";
+NSString *const kAppiraterAppIdBundleKey = @"AppStoreId";
NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID";
@@ -90,6 +91,12 @@ - (BOOL)connectedToNetwork {
return ((isReachable && !needsConnection) || nonWiFi) ? (testConnection ? YES : NO) : NO;
}
++ (NSString*)appStoreAppID {
+ NSString* value = [[[NSBundle mainBundle] infoDictionary] objectForKey:kAppiraterAppIdBundleKey];
+ NSAssert1(value, @"Error - you have not specified %@ property in your info.plist", kAppiraterAppIdBundleKey);
+ return value;
+}
+
+ (Appirater*)sharedInstance {
static Appirater *appirater = nil;
if (appirater == nil)
@@ -339,7 +346,7 @@ + (void)rateApp {
NSLog(@"APPIRATER NOTE: iTunes App Store is not supported on the iOS simulator. Unable to open App Store page.");
#else
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
- NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]];
+ NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", [self appStoreAppID]]];
@g-mark
g-mark added a note

Should be:
NSString reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[self appStoreAppID]];
since [self appStoreAppID] returns an NSString
, and not an int.

Then you don't need the string format, the code was written using the constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
[userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
[userDefaults synchronize];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]];
Something went wrong with that request. Please try again.