Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom Rating UI #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Appirater.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
*/
Expand Down
42 changes: 25 additions & 17 deletions Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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<AppiraterDelegate> _delegate;
#else
Expand Down Expand Up @@ -108,6 +110,9 @@ + (void) setTimeBeforeReminding:(double)value {
+ (void) setDebug:(BOOL)debug {
_debug = debug;
}
+ (void) setShowAlert:(BOOL)showAlert {
_showAlert = showAlert;
}
+ (void)setDelegate:(id<AppiraterDelegate>)delegate{
_delegate = delegate;
}
Expand Down Expand Up @@ -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 <AppiraterDelegate> delegate = _delegate;
if (delegate && [delegate respondsToSelector:@selector(appiraterDidDisplayAlert:)]) {
Expand Down