From b916080a19c2217142145e01de6262bc4a2948a4 Mon Sep 17 00:00:00 2001 From: Rocco Del Priore Date: Tue, 9 Jan 2018 21:47:51 -0800 Subject: [PATCH 1/3] Implement SKStoreReviewController support for iOS 10.3 & higher. --- UAAppReviewManager.m | 81 +++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/UAAppReviewManager.m b/UAAppReviewManager.m index e3d32b9..529aeb2 100644 --- a/UAAppReviewManager.m +++ b/UAAppReviewManager.m @@ -10,6 +10,7 @@ #import "UAAppReviewManager.h" #import +#import #include #if ! __has_feature(objc_arc) @@ -833,46 +834,56 @@ - (BOOL)userHasRatedCurrentVersion { #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)showRatingAlert { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:self.reviewTitle - message:self.reviewMessage - delegate:self - cancelButtonTitle:self.cancelButtonTitle - otherButtonTitles:(self.showsRemindButton ? self.remindButtonTitle : self.rateButtonTitle), // If we have a remind button, show it first. Otherwise show the rate button - (self.showsRemindButton ? self.rateButtonTitle : nil), // If we have a remind button, show the rate button next. Otherwise stop adding buttons. - nil]; - alertView.cancelButtonIndex = -1; - self.ratingAlert = alertView; - [alertView show]; - - if (self.didDisplayAlertBlock) - self.didDisplayAlertBlock(); + if (UAAppReviewManagerSystemVersionGreaterThanOrEqualTo(@"10.3")) { + [SKStoreReviewController requestReview]; + } + else { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:self.reviewTitle + message:self.reviewMessage + delegate:self + cancelButtonTitle:self.cancelButtonTitle + otherButtonTitles:(self.showsRemindButton ? self.remindButtonTitle : self.rateButtonTitle), // If we have a remind button, show it first. Otherwise show the rate button + (self.showsRemindButton ? self.rateButtonTitle : nil), // If we have a remind button, show the rate button next. Otherwise stop adding buttons. + nil]; + alertView.cancelButtonIndex = -1; + self.ratingAlert = alertView; + [alertView show]; + + if (self.didDisplayAlertBlock) + self.didDisplayAlertBlock(); + } } #else - (void)showRatingAlert { - NSAlert *alert = [NSAlert new]; - alert.messageText = self.reviewTitle; - alert.informativeText = self.reviewMessage; - [alert addButtonWithTitle:self.rateButtonTitle]; - [alert addButtonWithTitle:self.remindButtonTitle]; - [alert addButtonWithTitle:self.cancelButtonTitle]; - self.ratingAlert = alert; - - NSWindow *window = [[NSApplication sharedApplication] keyWindow]; - if (window) { - // TODO: Deprecated function - [alert beginSheetModalForWindow:[[NSApplication sharedApplication] keyWindow] - modalDelegate:self - didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:nil]; - } else { - NSInteger returnCode = [alert runModal]; - [self handleNSAlertReturnCode:returnCode]; - } - - if (self.didDisplayAlertBlock) - self.didDisplayAlertBlock(); + if (UAAppReviewManagerSystemVersionGreaterThanOrEqualTo(@"10.3")) { + [SKStoreReviewController requestReview]; + } + else { + NSAlert *alert = [NSAlert new]; + alert.messageText = self.reviewTitle; + alert.informativeText = self.reviewMessage; + [alert addButtonWithTitle:self.rateButtonTitle]; + [alert addButtonWithTitle:self.remindButtonTitle]; + [alert addButtonWithTitle:self.cancelButtonTitle]; + self.ratingAlert = alert; + + NSWindow *window = [[NSApplication sharedApplication] keyWindow]; + if (window) { + // TODO: Deprecated function + [alert beginSheetModalForWindow:[[NSApplication sharedApplication] keyWindow] + modalDelegate:self + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:nil]; + } else { + NSInteger returnCode = [alert runModal]; + [self handleNSAlertReturnCode:returnCode]; + } + + if (self.didDisplayAlertBlock) + self.didDisplayAlertBlock(); + } } #endif From 2c0560a939bcba2770f1b889b697510abcb91e97 Mon Sep 17 00:00:00 2001 From: Rocco Del Priore Date: Tue, 9 Jan 2018 22:00:11 -0800 Subject: [PATCH 2/3] Appropriately import frameworks. --- UAAppReviewManager.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/UAAppReviewManager.h b/UAAppReviewManager.h index ea51d4c..099daef 100644 --- a/UAAppReviewManager.h +++ b/UAAppReviewManager.h @@ -8,10 +8,13 @@ // -#import +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import -#import +#else +#import +#endif +#import //! Project version number for UAAppReviewManager. FOUNDATION_EXPORT double UAAppReviewManagerVersionNumber; From 48c4a8a32951179c12e09fa7289e500bbcf16bb1 Mon Sep 17 00:00:00 2001 From: Rocco Del Priore Date: Tue, 23 Jan 2018 20:35:45 -0800 Subject: [PATCH 3/3] Call didDisplayAlertBlock even when reviewed by SKStoreReviewController. --- UAAppReviewManager.m | 55 ++++++++++++++++++-------------------- UAAppReviewManager.podspec | 2 +- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/UAAppReviewManager.m b/UAAppReviewManager.m index 529aeb2..bb4c32d 100644 --- a/UAAppReviewManager.m +++ b/UAAppReviewManager.m @@ -836,6 +836,7 @@ - (BOOL)userHasRatedCurrentVersion { - (void)showRatingAlert { if (UAAppReviewManagerSystemVersionGreaterThanOrEqualTo(@"10.3")) { [SKStoreReviewController requestReview]; + [self remindMeLater]; } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:self.reviewTitle @@ -848,42 +849,38 @@ - (void)showRatingAlert { alertView.cancelButtonIndex = -1; self.ratingAlert = alertView; [alertView show]; - - if (self.didDisplayAlertBlock) - self.didDisplayAlertBlock(); + } + + if (self.didDisplayAlertBlock) { + self.didDisplayAlertBlock(); } } #else - (void)showRatingAlert { - if (UAAppReviewManagerSystemVersionGreaterThanOrEqualTo(@"10.3")) { - [SKStoreReviewController requestReview]; - } - else { - NSAlert *alert = [NSAlert new]; - alert.messageText = self.reviewTitle; - alert.informativeText = self.reviewMessage; - [alert addButtonWithTitle:self.rateButtonTitle]; - [alert addButtonWithTitle:self.remindButtonTitle]; - [alert addButtonWithTitle:self.cancelButtonTitle]; - self.ratingAlert = alert; - - NSWindow *window = [[NSApplication sharedApplication] keyWindow]; - if (window) { - // TODO: Deprecated function - [alert beginSheetModalForWindow:[[NSApplication sharedApplication] keyWindow] - modalDelegate:self - didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:nil]; - } else { - NSInteger returnCode = [alert runModal]; - [self handleNSAlertReturnCode:returnCode]; - } - - if (self.didDisplayAlertBlock) - self.didDisplayAlertBlock(); + NSAlert *alert = [NSAlert new]; + alert.messageText = self.reviewTitle; + alert.informativeText = self.reviewMessage; + [alert addButtonWithTitle:self.rateButtonTitle]; + [alert addButtonWithTitle:self.remindButtonTitle]; + [alert addButtonWithTitle:self.cancelButtonTitle]; + self.ratingAlert = alert; + + NSWindow *window = [[NSApplication sharedApplication] keyWindow]; + if (window) { + // TODO: Deprecated function + [alert beginSheetModalForWindow:[[NSApplication sharedApplication] keyWindow] + modalDelegate:self + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:nil]; + } else { + NSInteger returnCode = [alert runModal]; + [self handleNSAlertReturnCode:returnCode]; } + + if (self.didDisplayAlertBlock) + self.didDisplayAlertBlock(); } #endif diff --git a/UAAppReviewManager.podspec b/UAAppReviewManager.podspec index 3d7783b..ed9f109 100644 --- a/UAAppReviewManager.podspec +++ b/UAAppReviewManager.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "UAAppReviewManager" - s.version = "0.2.6" + s.version = "0.2.7" s.summary = "UAAppReviewManager is a simple and lightweight App review prompting tool for iOS and Mac App Store apps." s.description = <<-DESC UAAppReviewManager is a simple and lightweight App review prompting tool for iOS and Mac App Store apps. It allows you to use it on iOS and Mac targets, allows affiliate links and it rewritten from the ground up for the modern, primetime app.