// // iRate.h // // Version 1.7.4 // // Created by Nick Lockwood on 26/01/2011. // Copyright 2011 Charcoal Design // // Distributed under the permissive zlib license // Get the latest version from here: // // https://github.com/nicklockwood/iRate // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // #import #undef weak_delegate #if __has_feature(objc_arc_weak) && \ (!(defined __MAC_OS_X_VERSION_MIN_REQUIRED) || \ __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) #define weak_delegate weak #else #define weak_delegate unsafe_unretained #endif #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED #import #else #import #endif extern NSUInteger const iRateAppStoreGameGenreID; extern NSString *const iRateErrorDomain; //localisation string keys static NSString *const iRateMessageTitleKey = @"iRateMessageTitle"; static NSString *const iRateAppMessageKey = @"iRateAppMessage"; static NSString *const iRateGameMessageKey = @"iRateGameMessage"; static NSString *const iRateCancelButtonKey = @"iRateCancelButton"; static NSString *const iRateRemindButtonKey = @"iRateRemindButton"; static NSString *const iRateRateButtonKey = @"iRateRateButton"; /* Users will need to have the same version of your app installed for this many days before they will be prompted to rate it. */ #if VERSION_FREE #define APPIRATER_DAYS_UNTIL_PROMPT 4 // double #else #define APPIRATER_DAYS_UNTIL_PROMPT 10 // double #endif /* An example of a 'use' would be if the user launched the app. Bringing the app into the foreground (on devices that support it) would also be considered a 'use'. Users need to 'use' the same version of the app this many times before before they will be prompted to rate it. */ #define APPIRATER_USES_UNTIL_PROMPT -1 // integer /* Once the rating alert is presented to the user, they might select 'Remind me later'. This value specifies how long (in days) Appirater will wait before reminding them. */ #if VERSION_FREE #define APPIRATER_TIME_BEFORE_REMINDING 12 // double #else #define APPIRATER_TIME_BEFORE_REMINDING 30 // double #endif /* 用户选择了 No 按钮几次之后,不再弹出Appirater评价界面. */ #if VERSION_FREE #define APPIRATER_PROMPT_TIMES_UNTIL_REJECT 3 // double #else #define APPIRATER_PROMPT_TIMES_UNTIL_REJECT 2 // double #endif typedef enum { iRateErrorBundleIdDoesNotMatchAppStore = 1, iRateErrorApplicationNotFoundOnAppStore, iRateErrorApplicationIsNotLatestVersion } iRateErrorCode; @protocol iRateDelegate @optional - (void)iRateCouldNotConnectToAppStore:(NSError *)error; - (void)iRateDidDetectAppUpdate; - (BOOL)iRateShouldPromptForRating; - (void)iRateDidPromptForRating; - (void)iRateUserDidAttemptToRateApp; - (void)iRateUserDidDeclineToRateApp; - (void)iRateUserDidRequestReminderToRateApp; - (BOOL)iRateShouldOpenAppStore; - (void)iRateDidPresentStoreKitModal; - (void)iRateDidDismissStoreKitModal; @end @interface iRate : NSObject + (iRate *)sharedInstance; //app store ID - this is only needed if your //bundle ID is not unique between iOS and Mac app stores @property (nonatomic, assign) NSUInteger appStoreID; //application details - these are set automatically @property (nonatomic, assign) NSUInteger appStoreGenreID; @property (nonatomic, copy) NSString *appStoreCountry; @property (nonatomic, copy) NSString *applicationName; @property (nonatomic, copy) NSString *applicationVersion; @property (nonatomic, copy) NSString *applicationBundleID; //usage settings - these have sensible defaults @property (nonatomic, assign) NSUInteger usesUntilPrompt;// 使用几次后开始弹出 @property (nonatomic, assign) NSUInteger eventsUntilPrompt; @property (nonatomic, assign) float daysUntilPrompt;// 多少天后开始弹出 @property (nonatomic, assign) float usesPerWeekForPrompt; @property (nonatomic, assign) float remindPeriod;// 选择“稍后提醒我”后的再提醒时间间隔 //message text, you may wish to customise these @property (nonatomic, copy) NSString *messageTitle; @property (nonatomic, copy) NSString *message; @property (nonatomic, copy) NSString *cancelButtonLabel; @property (nonatomic, copy) NSString *remindButtonLabel; @property (nonatomic, copy) NSString *rateButtonLabel; //debugging and prompt overrides @property (nonatomic, assign) BOOL useAllAvailableLanguages; @property (nonatomic, assign) BOOL disableAlertViewResizing; @property (nonatomic, assign) BOOL promptAgainForEachNewVersion; @property (nonatomic, assign) BOOL onlyPromptIfLatestVersion; @property (nonatomic, assign) BOOL onlyPromptIfMainWindowIsAvailable; @property (nonatomic, assign) BOOL displayAppUsingStorekitIfAvailable; @property (nonatomic, assign) BOOL promptAtLaunch;// 启动或者回到前台就尝试提醒 @property (nonatomic, assign) BOOL verboseLogging; @property (nonatomic, assign) BOOL previewMode; //advanced properties for implementing custom behaviour @property (nonatomic, strong) NSURL *ratingsURL; @property (nonatomic, strong) NSDate *firstUsed; @property (nonatomic, strong) NSDate *lastReminded; @property (nonatomic, assign) NSUInteger usesCount; @property (nonatomic, assign) NSUInteger eventCount; @property (nonatomic, readonly) float usesPerWeek; @property (nonatomic, assign) BOOL declinedThisVersion; @property (nonatomic, readonly) BOOL declinedAnyVersion; @property (nonatomic, assign) BOOL ratedThisVersion; @property (nonatomic, readonly) BOOL ratedAnyVersion; @property (nonatomic, weak_delegate) id delegate; //manually control behaviour - (BOOL)shouldPromptForRating; - (void)promptForRating; - (void)promptIfNetworkAvailable; - (void)openRatingsPageInAppStore; - (void)logEvent:(BOOL)deferPrompt; - (void)remindMeLater; - (void)appLaunched; @end