Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added API method to close open modals.

  • Loading branch information...
commit d7b529d30b5b69c9170da22a0388402a6c608dc4 1 parent e158942
@ngreenstein ngreenstein authored
Showing with 25 additions and 5 deletions.
  1. +5 −0 Appirater.h
  2. +20 −5 Appirater.m
View
5 Appirater.h
@@ -155,6 +155,11 @@ extern NSString *const kAppiraterReminderRequestDate;
*/
+ (void)rateApp;
+/*
+ Tells Appirater to immediately close any open rating modals (e.g. StoreKit rating VCs).
+*/
++ (void)closeModal;
+
@end
@interface Appirater(Configuration)
View
25 Appirater.m
@@ -57,6 +57,7 @@
static id<AppiraterDelegate> _delegate;
static BOOL _usesAnimation = TRUE;
static UIStatusBarStyle _statusBarStyle;
+static BOOL _modalOpen = false;
@interface Appirater ()
- (BOOL)connectedToNetwork;
@@ -103,6 +104,9 @@ + (void)setUsesAnimation:(BOOL)animation {
+ (void)setStatusBarStyle:(UIStatusBarStyle)style {
_statusBarStyle = style;
}
++ (void)setModalOpen:(BOOL)open {
+ _modalOpen = open;
+}
- (BOOL)connectedToNetwork {
// Create zero addy
@@ -383,6 +387,7 @@ + (void)rateApp {
storeViewController.delegate = self.sharedInstance;
[self.sharedInstance.delegate appiraterWillPresentModalView:self.sharedInstance animated:_usesAnimation];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:storeViewController animated:_usesAnimation completion:^{
+ [self setModalOpen:YES];
//Temporarily use a black status bar to match the StoreKit view.
[self setStatusBarStyle:[UIApplication sharedApplication].statusBarStyle];
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:_usesAnimation];
@@ -436,12 +441,22 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
}
}
-//Close the in-app rating (StoreKit) view and restore the previous status bar style.
+//Delegate call from the StoreKit view.
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
- [[UIApplication sharedApplication]setStatusBarStyle:_statusBarStyle animated:_usesAnimation];
- [[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:_usesAnimation completion:nil];
- [self.class setStatusBarStyle:(UIStatusBarStyle)nil];
- [self.delegate appiraterDidDismissModalView:self animated:_usesAnimation];
+ [Appirater closeModal];
+}
+
+//Close the in-app rating (StoreKit) view and restore the previous status bar style.
++ (void)closeModal {
+ if (_modalOpen) {
+ [[UIApplication sharedApplication]setStatusBarStyle:_statusBarStyle animated:_usesAnimation];
+ BOOL usedAnimation = _usesAnimation;
+ [self setModalOpen:NO];
+ [[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:_usesAnimation completion:^{
+ [self.sharedInstance.delegate appiraterDidDismissModalView:(Appirater *)self animated:usedAnimation];
+ }];
+ [self.class setStatusBarStyle:(UIStatusBarStyle)nil];
+ }
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.