iRate.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // iRate.h
  3. //
  4. // Version 1.11.6
  5. //
  6. // Created by Nick Lockwood on 26/01/2011.
  7. // Copyright 2011 Charcoal Design
  8. //
  9. // Distributed under the permissive zlib license
  10. // Get the latest version from here:
  11. //
  12. // https://github.com/nicklockwood/iRate
  13. //
  14. // This software is provided 'as-is', without any express or implied
  15. // warranty. In no event will the authors be held liable for any damages
  16. // arising from the use of this software.
  17. //
  18. // Permission is granted to anyone to use this software for any purpose,
  19. // including commercial applications, and to alter it and redistribute it
  20. // freely, subject to the following restrictions:
  21. //
  22. // 1. The origin of this software must not be misrepresented; you must not
  23. // claim that you wrote the original software. If you use this software
  24. // in a product, an acknowledgment in the product documentation would be
  25. // appreciated but is not required.
  26. //
  27. // 2. Altered source versions must be plainly marked as such, and must not be
  28. // misrepresented as being the original software.
  29. //
  30. // 3. This notice may not be removed or altered from any source distribution.
  31. //
  32. #pragma clang diagnostic push
  33. #pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis"
  34. #import <Availability.h>
  35. #undef weak_delegate
  36. #if __has_feature(objc_arc_weak) && \
  37. (TARGET_OS_IPHONE || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8)
  38. #define weak_delegate weak
  39. #else
  40. #define weak_delegate unsafe_unretained
  41. #endif
  42. #import <TargetConditionals.h>
  43. #if TARGET_OS_IPHONE
  44. #import <UIKit/UIKit.h>
  45. #define IRATE_EXTERN UIKIT_EXTERN
  46. #else
  47. #import <Cocoa/Cocoa.h>
  48. #define IRATE_EXTERN APPKIT_EXTERN
  49. #endif
  50. //! Project version number for iRate.
  51. FOUNDATION_EXPORT double iRateVersionNumber;
  52. //! Project version string for iRate.
  53. FOUNDATION_EXPORT const unsigned char iRateVersionString[];
  54. IRATE_EXTERN NSUInteger const iRateAppStoreGameGenreID;
  55. IRATE_EXTERN NSString *const iRateErrorDomain;
  56. //localisation string keys
  57. IRATE_EXTERN NSString *const iRateMessageTitleKey; //iRateMessageTitle
  58. IRATE_EXTERN NSString *const iRateAppMessageKey; //iRateAppMessage
  59. IRATE_EXTERN NSString *const iRateGameMessageKey; //iRateGameMessage
  60. IRATE_EXTERN NSString *const iRateUpdateMessageKey; //iRateUpdateMessage
  61. IRATE_EXTERN NSString *const iRateCancelButtonKey; //iRateCancelButton
  62. IRATE_EXTERN NSString *const iRateRemindButtonKey; //iRateRemindButton
  63. IRATE_EXTERN NSString *const iRateRateButtonKey; //iRateRateButton
  64. //notification keys
  65. IRATE_EXTERN NSString *const iRateCouldNotConnectToAppStore;
  66. IRATE_EXTERN NSString *const iRateDidDetectAppUpdate;
  67. IRATE_EXTERN NSString *const iRateDidPromptForRating;
  68. IRATE_EXTERN NSString *const iRateUserDidAttemptToRateApp;
  69. IRATE_EXTERN NSString *const iRateUserDidDeclineToRateApp;
  70. IRATE_EXTERN NSString *const iRateUserDidRequestReminderToRateApp;
  71. IRATE_EXTERN NSString *const iRateDidOpenAppStore;
  72. typedef NS_ENUM(NSUInteger, iRateErrorCode)
  73. {
  74. iRateErrorBundleIdDoesNotMatchAppStore = 1,
  75. iRateErrorApplicationNotFoundOnAppStore,
  76. iRateErrorApplicationIsNotLatestVersion,
  77. iRateErrorCouldNotOpenRatingPageURL
  78. };
  79. @protocol iRateDelegate <NSObject>
  80. @optional
  81. - (void)iRateCouldNotConnectToAppStore:(NSError *)error;
  82. - (void)iRateDidDetectAppUpdate;
  83. - (BOOL)iRateShouldPromptForRating;
  84. - (void)iRateDidPromptForRating;
  85. - (void)iRateUserDidAttemptToRateApp;
  86. - (void)iRateUserDidDeclineToRateApp;
  87. - (void)iRateUserDidRequestReminderToRateApp;
  88. - (BOOL)iRateShouldOpenAppStore;
  89. - (void)iRateDidOpenAppStore;
  90. @end
  91. @interface iRate : NSObject
  92. + (instancetype)sharedInstance;
  93. //app store ID - this is only needed if your
  94. //bundle ID is not unique between iOS and Mac app stores
  95. @property (nonatomic, assign) NSUInteger appStoreID;
  96. //application details - these are set automatically
  97. @property (nonatomic, assign) NSUInteger appStoreGenreID;
  98. @property (nonatomic, copy) NSString *appStoreCountry;
  99. @property (nonatomic, copy) NSString *applicationName;
  100. @property (nonatomic, copy) NSString *applicationVersion;
  101. @property (nonatomic, copy) NSString *applicationBundleID;
  102. //usage settings - these have sensible defaults
  103. @property (nonatomic, assign) NSUInteger usesUntilPrompt;
  104. @property (nonatomic, assign) NSUInteger eventsUntilPrompt;
  105. @property (nonatomic, assign) float daysUntilPrompt;
  106. @property (nonatomic, assign) float usesPerWeekForPrompt;
  107. @property (nonatomic, assign) float remindPeriod;
  108. //message text, you may wish to customise these
  109. @property (nonatomic, copy) NSString *messageTitle;
  110. @property (nonatomic, copy) NSString *message;
  111. @property (nonatomic, copy) NSString *updateMessage;
  112. @property (nonatomic, copy) NSString *cancelButtonLabel;
  113. @property (nonatomic, copy) NSString *remindButtonLabel;
  114. @property (nonatomic, copy) NSString *rateButtonLabel;
  115. //debugging and prompt overrides
  116. @property (nonatomic, assign) BOOL useUIAlertControllerIfAvailable;
  117. @property (nonatomic, assign) BOOL useAllAvailableLanguages;
  118. @property (nonatomic, assign) BOOL promptForNewVersionIfUserRated;
  119. @property (nonatomic, assign) BOOL onlyPromptIfLatestVersion;
  120. @property (nonatomic, assign) BOOL onlyPromptIfMainWindowIsAvailable;
  121. @property (nonatomic, assign) BOOL promptAtLaunch;
  122. @property (nonatomic, assign) BOOL verboseLogging;
  123. @property (nonatomic, assign) BOOL previewMode;
  124. //advanced properties for implementing custom behaviour
  125. @property (nonatomic, strong) NSURL *ratingsURL;
  126. @property (nonatomic, strong) NSDate *firstUsed;
  127. @property (nonatomic, strong) NSDate *lastReminded;
  128. @property (nonatomic, assign) NSUInteger usesCount;
  129. @property (nonatomic, assign) NSUInteger eventCount;
  130. @property (nonatomic, readonly) float usesPerWeek;
  131. @property (nonatomic, assign) BOOL declinedThisVersion;
  132. @property (nonatomic, readonly) BOOL declinedAnyVersion;
  133. @property (nonatomic, assign) BOOL ratedThisVersion;
  134. @property (nonatomic, readonly) BOOL ratedAnyVersion;
  135. @property (nonatomic, weak_delegate) id<iRateDelegate> delegate;
  136. //manually control behaviour
  137. - (BOOL)shouldPromptForRating;
  138. - (void)promptForRating;
  139. - (void)promptIfNetworkAvailable;
  140. - (void)promptIfAllCriteriaMet;
  141. - (void)openRatingsPageInAppStore;
  142. - (void)logEvent:(BOOL)deferPrompt;
  143. - (void)remindLater;
  144. @end
  145. #pragma clang diagnostic pop