Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Mac App Store Support #9

Open
wants to merge 1 commit into from

2 participants

Nick Lockwood Alexsander Akers
Nick Lockwood

I've added Mac App Store support to Appirater. It's unobtrusive and will compile on Mac or iPhone. Thought you might be interested in merging it in.

Alexsander Akers a2 commented on the diff
Appirater.m
((5 lines not shown))
NSString *templateReviewURL = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=APP_ID&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software";
+#else
+//annoyingly this seems to open in iTunes rather than the mac app store - couldn't find a way to deeplink to the mac app review panel
+//NSString *templateReviewURL = @"https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/addUserReview?id=APP_ID&onlyLatestVersion=true&type=Purple+Software";
+NSString *templateReviewURL = @"http://itunes.apple.com/us/app/rainbow-blocks/idAPP_ID?mt=12&ls=1";
Alexsander Akers
a2 added a note

You can use this URL, which I got from the app display page on Apple's website:

macappstore://itunes.apple.com/us/app/lexicon-romanum/idAPP_ID?mt=12

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 Jan 8, 2011
  1. Added support for Mac App Store

    Nick Lockwood authored
This page is out of date. Refresh to see the latest.
Showing with 82 additions and 12 deletions.
  1. +7 −3 Appirater.h
  2. +75 −9 Appirater.m
10 Appirater.h
View
@@ -35,6 +35,8 @@
*/
#import <Foundation/Foundation.h>
+#import <Availability.h>
+
extern NSString *const kAppiraterFirstUseDate;
extern NSString *const kAppiraterUseCount;
@@ -123,9 +125,11 @@ extern NSString *const kAppiraterDeclinedToRate;
*/
#define APPIRATER_DEBUG NO
-@interface Appirater : NSObject <UIAlertViewDelegate> {
-
-}
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+@interface Appirater : NSObject <UIAlertViewDelegate>
+#else
+@interface Appirater : NSObject
+#endif
/*
DEPRECATED: While still functional, it's better to use
84 Appirater.m
View
@@ -46,7 +46,14 @@
NSString *const kAppiraterDeclinedToRate = @"kAppiraterDeclinedToRate";
NSString *const kAppiraterReminderRequestDate = @"kAppiraterReminderRequestDate";
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
NSString *templateReviewURL = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=APP_ID&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software";
+#else
+//annoyingly this seems to open in iTunes rather than the mac app store - couldn't find a way to deeplink to the mac app review panel
+//NSString *templateReviewURL = @"https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/addUserReview?id=APP_ID&onlyLatestVersion=true&type=Purple+Software";
+NSString *templateReviewURL = @"http://itunes.apple.com/us/app/rainbow-blocks/idAPP_ID?mt=12&ls=1";
Alexsander Akers
a2 added a note

You can use this URL, which I got from the app display page on Apple's website:

macappstore://itunes.apple.com/us/app/lexicon-romanum/idAPP_ID?mt=12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+#endif
+
NSString *templateReviewURLIpad = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=APP_ID";
@@ -104,15 +111,6 @@ + (Appirater*)sharedInstance {
return appirater;
}
-- (void)showRatingAlert {
- UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:APPIRATER_MESSAGE_TITLE
- message:APPIRATER_MESSAGE
- delegate:self
- cancelButtonTitle:APPIRATER_CANCEL_BUTTON
- otherButtonTitles:APPIRATER_RATE_BUTTON, APPIRATER_RATE_LATER, nil] autorelease];
- [alertView show];
-}
-
- (BOOL)ratingConditionsHaveBeenMet {
if (APPIRATER_DEBUG)
return YES;
@@ -249,6 +247,34 @@ - (void)incrementSignificantEventCount {
[userDefaults synchronize];
}
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+
+- (void)showRatingAlert {
+ UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:APPIRATER_MESSAGE_TITLE
+ message:APPIRATER_MESSAGE
+ delegate:self
+ cancelButtonTitle:APPIRATER_CANCEL_BUTTON
+ otherButtonTitles:APPIRATER_RATE_BUTTON, APPIRATER_RATE_LATER, nil] autorelease];
+ [alertView show];
+}
+
+#else
+
+- (void)showRatingAlert {
+ NSAlert *alert = [NSAlert alertWithMessageText:APPIRATER_MESSAGE_TITLE
+ defaultButton:APPIRATER_RATE_BUTTON
+ alternateButton:APPIRATER_CANCEL_BUTTON
+ otherButton:APPIRATER_RATE_LATER
+ informativeTextWithFormat:APPIRATER_MESSAGE];
+
+ [alert beginSheetModalForWindow:[[NSApplication sharedApplication] mainWindow]
+ modalDelegate:self
+ didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
+ contextInfo:nil];
+}
+
+#endif
+
@end
@@ -293,12 +319,15 @@ + (void)appLaunched:(BOOL)canPromptForRating {
multitasking devices also get a usage call when they come
into the foreground and we don't want to count app launches
as two uses on multitasking devices. */
+
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
UIDevice *device = [UIDevice currentDevice];
if ([device respondsToSelector:@selector(multitaskingSupported)] &&
[device multitaskingSupported])
{
return;
}
+#endif
NSNumber *_canPromptForRating = [[NSNumber alloc] initWithBool:canPromptForRating];
[NSThread detachNewThreadSelector:@selector(incrementAndRate:)
@@ -323,6 +352,8 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating {
[_canPromptForRating release];
}
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
@@ -364,4 +395,39 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
}
}
+#else
+
+- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
+ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+
+ switch (returnCode) {
+ case NSAlertAlternateReturn:
+ {
+ // they don't want to rate it
+ [userDefaults setBool:YES forKey:kAppiraterDeclinedToRate];
+ break;
+ }
+ case NSAlertDefaultReturn:
+ {
+ // they want to rate it
+ NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]];
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:reviewURL]];
+
+ [userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
+ break;
+ }
+ case NSAlertOtherReturn:
+ // remind them later
+ break;
+ default:
+ break;
+ }
+
+ [userDefaults synchronize];
+
+ [self release];
+}
+
+#endif
+
@end
Something went wrong with that request. Please try again.