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 */ 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:)]) {