From 3ca5e01118f1c88f989334575acd86f2b073676f Mon Sep 17 00:00:00 2001 From: xialin Date: Sat, 15 Feb 2014 15:52:34 +0800 Subject: [PATCH 1/2] added showAlert flag. when set NO, app can use customised Rating UI instead of AlertView. --- Appirater.m | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Appirater.m b/Appirater.m index c20ebc3f..9730a995 100644 --- a/Appirater.m +++ b/Appirater.m @@ -49,6 +49,7 @@ NSString *const kAppiraterRatedCurrentVersion = @"kAppiraterRatedCurrentVersion"; NSString *const kAppiraterDeclinedToRate = @"kAppiraterDeclinedToRate"; NSString *const kAppiraterReminderRequestDate = @"kAppiraterReminderRequestDate"; +NSString *const kAppiraterShowRatingAlert = @"kShowRatingAlert"; NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID"; NSString *templateReviewURLiOS7 = @"itms-apps://itunes.apple.com/app/idAPP_ID"; @@ -59,6 +60,7 @@ static NSInteger _significantEventsUntilPrompt = -1; static double _timeBeforeReminding = 1; static BOOL _debug = NO; +static BOOL _showAlert = YES; #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 static id _delegate; #else @@ -108,6 +110,9 @@ + (void) setTimeBeforeReminding:(double)value { + (void) setDebug:(BOOL)debug { _debug = debug; } ++ (void) setShowAlert:(BOOL)showAlert { + _showAlert = showAlert; +} + (void)setDelegate:(id)delegate{ _delegate = delegate; } @@ -208,23 +213,26 @@ + (Appirater*)sharedInstance { } - (void)showRatingAlert:(BOOL)displayRateLaterButton { - UIAlertView *alertView = nil; - if (displayRateLaterButton) { - alertView = [[UIAlertView alloc] initWithTitle:APPIRATER_MESSAGE_TITLE - message:APPIRATER_MESSAGE - delegate:self - cancelButtonTitle:APPIRATER_CANCEL_BUTTON - otherButtonTitles:APPIRATER_RATE_BUTTON, APPIRATER_RATE_LATER, nil]; - } else { - alertView = [[UIAlertView alloc] initWithTitle:APPIRATER_MESSAGE_TITLE - message:APPIRATER_MESSAGE - delegate:self - cancelButtonTitle:APPIRATER_CANCEL_BUTTON - otherButtonTitles:APPIRATER_RATE_BUTTON, nil]; - } - - self.ratingAlert = alertView; - [alertView show]; + if (_showAlert) { + UIAlertView *alertView = nil; + if (displayRateLaterButton) { + alertView = [[UIAlertView alloc] initWithTitle:APPIRATER_MESSAGE_TITLE + message:APPIRATER_MESSAGE + delegate:self + cancelButtonTitle:APPIRATER_CANCEL_BUTTON + otherButtonTitles:APPIRATER_RATE_BUTTON, APPIRATER_RATE_LATER, nil]; + } else { + alertView = [[UIAlertView alloc] initWithTitle:APPIRATER_MESSAGE_TITLE + message:APPIRATER_MESSAGE + delegate:self + cancelButtonTitle:APPIRATER_CANCEL_BUTTON + otherButtonTitles:APPIRATER_RATE_BUTTON, nil]; + } + self.ratingAlert = alertView; + [alertView show]; + } else { + [[NSNotificationCenter defaultCenter] postNotificationName:kAppiraterShowRatingAlert object:nil]; + } id delegate = _delegate; if (delegate && [delegate respondsToSelector:@selector(appiraterDidDisplayAlert:)]) { From 062d42906b56a9dcfe4893fc23aa8123c0d4e60e Mon Sep 17 00:00:00 2001 From: xialin Date: Sat, 15 Feb 2014 16:40:29 +0800 Subject: [PATCH 2/2] updated .h file --- Appirater.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Appirater.h b/Appirater.h index b0d5f582..742f2618 100644 --- a/Appirater.h +++ b/Appirater.h @@ -45,6 +45,7 @@ extern NSString *const kAppiraterCurrentVersion; extern NSString *const kAppiraterRatedCurrentVersion; extern NSString *const kAppiraterDeclinedToRate; extern NSString *const kAppiraterReminderRequestDate; +extern NSString *const kAppiraterShowRatingAlert; /*! Your localized app's name. @@ -236,6 +237,8 @@ extern NSString *const kAppiraterReminderRequestDate; */ + (void) setDebug:(BOOL)debug; ++ (void) setShowAlert:(BOOL)showAlert; + /*! Set the delegate if you want to know when Appirater does something */