Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Appirater now requires iOS 4

Fixed a NSURLConnection leak
Added German, French, and Japanese localizations
Added a missing const variable
Appirater singleton is initialized with dispatch_once
Updated README instructions
  • Loading branch information...
commit 930582793c3cccd0f31fec50d52a2a54458404b9 1 parent 216cb84
Arash Payan authored
View
18 Appirater.h
@@ -1,7 +1,7 @@
/*
This file is part of Appirater.
- Copyright (c) 2010, Arash Payan
+ Copyright (c) 2012, Arash Payan
All rights reserved.
Permission is hereby granted, free of charge, to any person
@@ -31,7 +31,7 @@
*
* Created by Arash Payan on 9/5/09.
* http://arashpayan.com
- * Copyright 2010 Arash Payan. All rights reserved.
+ * Copyright 2012 Arash Payan. All rights reserved.
*/
#import <Foundation/Foundation.h>
@@ -42,6 +42,7 @@ extern NSString *const kAppiraterSignificantEventCount;
extern NSString *const kAppiraterCurrentVersion;
extern NSString *const kAppiraterRatedCurrentVersion;
extern NSString *const kAppiraterDeclinedToRate;
+extern NSString *const kAppiraterReminderRequestDate;
/*
Place your Apple generated software id here.
@@ -57,27 +58,30 @@ extern NSString *const kAppiraterDeclinedToRate;
This is the message your users will see once they've passed the day+launches
threshold.
*/
-#define APPIRATER_MESSAGE [NSString stringWithFormat:@"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!", APPIRATER_APP_NAME]
+#define APPIRATER_LOCALIZED_MESSAGE NSLocalizedString(@"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!", nil)
+#define APPIRATER_MESSAGE [NSString stringWithFormat:APPIRATER_LOCALIZED_MESSAGE, APPIRATER_APP_NAME]
/*
This is the title of the message alert that users will see.
*/
-#define APPIRATER_MESSAGE_TITLE [NSString stringWithFormat:@"Rate %@", APPIRATER_APP_NAME]
+#define APPIRATER_LOCALIZED_MESSAGE_TITLE NSLocalizedString(@"Rate %@", nil)
+#define APPIRATER_MESSAGE_TITLE [NSString stringWithFormat:APPIRATER_LOCALIZED_MESSAGE_TITLE, APPIRATER_APP_NAME]
/*
The text of the button that rejects reviewing the app.
*/
-#define APPIRATER_CANCEL_BUTTON @"No, Thanks"
+#define APPIRATER_CANCEL_BUTTON NSLocalizedString(@"No, Thanks", nil)
/*
Text of button that will send user to app review page.
*/
-#define APPIRATER_RATE_BUTTON [NSString stringWithFormat:@"Rate %@", APPIRATER_APP_NAME]
+#define APPIRATER_LOCALIZED_RATE_BUTTON NSLocalizedString(@"Rate %@", nil)
+#define APPIRATER_RATE_BUTTON [NSString stringWithFormat:APPIRATER_LOCALIZED_RATE_BUTTON, APPIRATER_APP_NAME]
/*
Text for button to remind the user to review later.
*/
-#define APPIRATER_RATE_LATER @"Remind me later"
+#define APPIRATER_RATE_LATER NSLocalizedString(@"Remind me later", nil)
/*
Users will need to have the same version of your app installed for this many
View
90 Appirater.m
@@ -1,7 +1,7 @@
/*
This file is part of Appirater.
- Copyright (c) 2010, Arash Payan
+ Copyright (c) 2012, Arash Payan
All rights reserved.
Permission is hereby granted, free of charge, to any person
@@ -31,7 +31,7 @@
*
* Created by Arash Payan on 9/5/09.
* http://arashpayan.com
- * Copyright 2010 Arash Payan. All rights reserved.
+ * Copyright 2012 Arash Payan. All rights reserved.
*/
#import "Appirater.h"
@@ -48,16 +48,18 @@
NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID";
-
-@interface Appirater (hidden)
+@interface Appirater ()
- (BOOL)connectedToNetwork;
+ (Appirater*)sharedInstance;
- (void)showRatingAlert;
- (BOOL)ratingConditionsHaveBeenMet;
- (void)incrementUseCount;
+- (void)hideRatingAlert;
@end
-@implementation Appirater (hidden)
+@implementation Appirater
+
+@synthesize ratingAlert;
- (BOOL)connectedToNetwork {
// Create zero addy
@@ -85,7 +87,7 @@ - (BOOL)connectedToNetwork {
NSURL *testURL = [NSURL URLWithString:@"http://www.apple.com/"];
NSURLRequest *testRequest = [NSURLRequest requestWithURL:testURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0];
- NSURLConnection *testConnection = [[NSURLConnection alloc] initWithRequest:testRequest delegate:self];
+ NSURLConnection *testConnection = [[[NSURLConnection alloc] initWithRequest:testRequest delegate:self] autorelease];
return ((isReachable && !needsConnection) || nonWiFi) ? (testConnection ? YES : NO) : NO;
}
@@ -94,12 +96,12 @@ + (Appirater*)sharedInstance {
static Appirater *appirater = nil;
if (appirater == nil)
{
- @synchronized(self) {
- if (appirater == nil) {
- appirater = [[Appirater alloc] init];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive) name:@"UIApplicationWillResignActiveNotification" object:nil];
- }
- }
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ appirater = [[Appirater alloc] init];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive) name:
+ UIApplicationWillResignActiveNotification object:nil];
+ });
}
return appirater;
@@ -251,45 +253,32 @@ - (void)incrementSignificantEventCount {
[userDefaults synchronize];
}
-@end
-
-
-@interface Appirater ()
-- (void)hideRatingAlert;
-@end
-
-@implementation Appirater
-
-@synthesize ratingAlert;
-
-- (void)incrementAndRate:(NSNumber*)_canPromptForRating {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+- (void)incrementAndRate:(BOOL)canPromptForRating {
[self incrementUseCount];
- if ([_canPromptForRating boolValue] == YES &&
+ if (canPromptForRating &&
[self ratingConditionsHaveBeenMet] &&
[self connectedToNetwork])
{
- [self performSelectorOnMainThread:@selector(showRatingAlert) withObject:nil waitUntilDone:NO];
+ dispatch_async(dispatch_get_main_queue(),
+ ^{
+ [self showRatingAlert];
+ });
}
-
- [pool release];
}
-- (void)incrementSignificantEventAndRate:(NSNumber*)_canPromptForRating {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+- (void)incrementSignificantEventAndRate:(BOOL)canPromptForRating {
[self incrementSignificantEventCount];
- if ([_canPromptForRating boolValue] == YES &&
+ if (canPromptForRating &&
[self ratingConditionsHaveBeenMet] &&
[self connectedToNetwork])
{
- [self performSelectorOnMainThread:@selector(showRatingAlert) withObject:nil waitUntilDone:NO];
+ dispatch_async(dispatch_get_main_queue(),
+ ^{
+ [self showRatingAlert];
+ });
}
-
- [pool release];
}
+ (void)appLaunched {
@@ -297,11 +286,10 @@ + (void)appLaunched {
}
+ (void)appLaunched:(BOOL)canPromptForRating {
- NSNumber *_canPromptForRating = [[NSNumber alloc] initWithBool:canPromptForRating];
- [NSThread detachNewThreadSelector:@selector(incrementAndRate:)
- toTarget:[Appirater sharedInstance]
- withObject:_canPromptForRating];
- [_canPromptForRating release];
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0),
+ ^{
+ [[Appirater sharedInstance] incrementAndRate:canPromptForRating];
+ });
}
- (void)hideRatingAlert {
@@ -319,19 +307,17 @@ + (void)appWillResignActive {
}
+ (void)appEnteredForeground:(BOOL)canPromptForRating {
- NSNumber *_canPromptForRating = [[NSNumber alloc] initWithBool:canPromptForRating];
- [NSThread detachNewThreadSelector:@selector(incrementAndRate:)
- toTarget:[Appirater sharedInstance]
- withObject:_canPromptForRating];
- [_canPromptForRating release];
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0),
+ ^{
+ [[Appirater sharedInstance] incrementAndRate:canPromptForRating];
+ });
}
+ (void)userDidSignificantEvent:(BOOL)canPromptForRating {
- NSNumber *_canPromptForRating = [[NSNumber alloc] initWithBool:canPromptForRating];
- [NSThread detachNewThreadSelector:@selector(incrementSignificantEventAndRate:)
- toTarget:[Appirater sharedInstance]
- withObject:_canPromptForRating];
- [_canPromptForRating release];
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0),
+ ^{
+ [[Appirater sharedInstance] incrementSignificantEventAndRate:canPromptForRating];
+ });
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
View
13 README.md
@@ -1,10 +1,11 @@
Introduction
------------
-Appirater is a class that you can drop into any iPhone app that will help remind your users
+Appirater is a class that you can drop into any iPhone app (iOS 4.0 or later) that will help remind your users
to review your app on the App Store. The code is released under the MIT/X11, so feel free to
modify and share your changes with the world. To find out more, check out the [project
homepage] [homepage].
+
Getting Started
---------------
1. Add the Appirater code into your project
@@ -16,11 +17,17 @@ Getting Started
License
-------
-Copyright 2010. [Arash Payan] [arash].
+Copyright 2012. [Arash Payan] [arash].
This library is distributed under the terms of the MIT/X11.
While not required, I greatly encourage and appreciate any improvements that you make
to this library be contributed back for the benefit of all who use Appirater.
+MonoTouch Port
+--------------
+[Ivan Nikitin] [ivan] has ported Appirater to MonoTouch. You can find [it here on github] [monotouchport].
+
[homepage]: http://arashpayan.com/blog/index.php/2009/09/07/presenting-appirater/
-[arash]: http://arashpayan.com
+[arash]: http://arashpayan.com
+[ivan]: https://www.facebook.com/nikitinivan
+[monotouchport]: https://github.com/chebum/Appirater-for-MonoTouch
View
4 de.lproj/Localizable.strings
@@ -0,0 +1,4 @@
+"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!" = "Wenn Sie %@ gerne nutzen, würden Sie sich bitte einen Moment Zeit nehmen, um zu bewerten? Es dauert nicht mehr als eine Minute. Vielen Dank für Ihre Unterstützung!";
+"Rate %@" = "Bewerte %@";
+"No, Thanks" = "Nein, Danke";
+"Remind me later" = "Später erinnern";
View
4 en.lproj/Localizable.strings
@@ -0,0 +1,4 @@
+"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!" = "If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!";
+"Rate %@" = "Rate %@";
+"No, Thanks" = "No, Thanks";
+"Remind me later" = "Remind me later";
View
4 fr.lproj/Localizable.strings
@@ -0,0 +1,4 @@
+"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!" = "Si vous aimez %@, voulez-vous prendre un moment pour l'évaluer? Il ne prendra pas plus d'une minute. Merci pour votre soutien!";
+"Rate %@" = "Taux %@";
+"No, Thanks" = "Non, Merci";
+"Remind me later" = "Rappelez-moi plus tard";
View
4 ja.lproj/Localizable.strings
@@ -0,0 +1,4 @@
+"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!" = "楽しんでいただけたならば簡単なご意見をお願いします。%@を評価しますか?";
+"Rate %@" = "%@の評価";
+"No, Thanks" ="いいえ";
+"Remind me later" = "後で見る";
Please sign in to comment.
Something went wrong with that request. Please try again.