From a7c6ec1e672239273c40047841c6da18d2dc14de Mon Sep 17 00:00:00 2001 From: Victor Ilyukevich Date: Fri, 5 Apr 2013 12:39:21 +0300 Subject: [PATCH] Added method to trigger prompting if needed --- iRate/iRate.h | 1 + iRate/iRate.m | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/iRate/iRate.h b/iRate/iRate.h index 3ffdd507..9160b3eb 100644 --- a/iRate/iRate.h +++ b/iRate/iRate.h @@ -144,6 +144,7 @@ iRateErrorCode; //manually control behaviour - (BOOL)shouldPromptForRating; - (void)promptForRating; +- (void)promptIfNeeded; - (void)promptIfNetworkAvailable; - (void)openRatingsPageInAppStore; - (void)logEvent:(BOOL)deferPrompt; diff --git a/iRate/iRate.m b/iRate/iRate.m index 9ca2b8c3..d77e671b 100644 --- a/iRate/iRate.m +++ b/iRate/iRate.m @@ -688,6 +688,14 @@ - (void)checkForConnectivityInBackground } } +- (void)promptIfNeeded +{ + if ([self shouldPromptForRating]) + { + [self promptIfNetworkAvailable]; + } +} + - (void)promptIfNetworkAvailable { if (!self.currentlyChecking) @@ -773,9 +781,9 @@ - (void)applicationLaunched } [self incrementUseCount]; - if (self.promptAtLaunch && [self shouldPromptForRating]) + if (self.promptAtLaunch) { - [self promptIfNetworkAvailable]; + [self promptIfNeeded]; } } @@ -786,9 +794,9 @@ - (void)applicationWillEnterForeground:(NSNotification *)notification if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { [self incrementUseCount]; - if (self.promptAtLaunch && [self shouldPromptForRating]) + if (self.promptAtLaunch) { - [self promptIfNetworkAvailable]; + [self promptIfNeeded]; } } } @@ -1111,9 +1119,9 @@ - (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInf - (void)logEvent:(BOOL)deferPrompt { [self incrementEventCount]; - if (!deferPrompt && [self shouldPromptForRating]) + if (!deferPrompt) { - [self promptIfNetworkAvailable]; + [self promptIfNeeded]; } }