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

Feature/SKStoreReviewController #42

Open
wants to merge 3 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
7 changes: 5 additions & 2 deletions UAAppReviewManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
//


#import <Cocoa/Cocoa.h>
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif

#import <StoreKit/StoreKit.h>

//! Project version number for UAAppReviewManager.
FOUNDATION_EXPORT double UAAppReviewManagerVersionNumber;
Expand Down
78 changes: 43 additions & 35 deletions UAAppReviewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#import "UAAppReviewManager.h"
#import <SystemConfiguration/SCNetworkReachability.h>
#import <StoreKit/StoreKit.h>
#include <netinet/in.h>

#if ! __has_feature(objc_arc)
Expand Down Expand Up @@ -833,46 +834,53 @@ - (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];
[self remindMeLater];
}
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();
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
Expand Down
2 changes: 1 addition & 1 deletion UAAppReviewManager.podspec
Original file line number Diff line number Diff line change
@@ -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.
Expand Down