ALIncentivizedInterstitialAd.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. //
  2. // ALIncentivizedInterstitialAd.h
  3. // AppLovinSDK
  4. //
  5. // Copyright © 2020 AppLovin Corporation. All rights reserved.
  6. //
  7. #import <AppLovinSDK/ALAdDisplayDelegate.h>
  8. #import <AppLovinSDK/ALAdLoadDelegate.h>
  9. #import <AppLovinSDK/ALAdRewardDelegate.h>
  10. #import <AppLovinSDK/ALAdVideoPlaybackDelegate.h>
  11. @class ALAd;
  12. @class ALSdk;
  13. NS_ASSUME_NONNULL_BEGIN
  14. /**
  15. * This class shows rewarded videos to the user. These differ from regular interstitials in that they allow you to provide your user virtual currency in
  16. * exchange for watching a video.
  17. */
  18. @interface ALIncentivizedInterstitialAd : NSObject
  19. #pragma mark - Ad Delegates
  20. /**
  21. * An object that conforms to the @c ALAdDisplayDelegate protocol. If you provide a value for @c adDisplayDelegate in your instance, the SDK will
  22. * notify this delegate of ad show/hide events.
  23. */
  24. @property (nonatomic, strong, nullable) id<ALAdDisplayDelegate> adDisplayDelegate;
  25. /**
  26. * An object that conforms to the @c ALAdVideoPlaybackDelegate protocol. If you provide a value for @c adVideoPlaybackDelegate in your instance,
  27. * the SDK will notify this delegate of video start/stop events.
  28. */
  29. @property (nonatomic, strong, nullable) id<ALAdVideoPlaybackDelegate> adVideoPlaybackDelegate;
  30. #pragma mark - Integration, Class Methods
  31. /**
  32. * Gets a reference to the shared instance of @c [ALIncentivizedInterstitialAd].
  33. *
  34. * This wraps the @code +[ALSdk shared] @endcode call, and will only work if you have set your SDK key in @code Info.plist @endcode.
  35. */
  36. + (ALIncentivizedInterstitialAd *)shared;
  37. /**
  38. * Pre-loads an incentivized interstitial, and notifies your provided Ad Load Delegate.
  39. *
  40. * Invoke this once to pre-load, then do not invoke it again until the ad has has been closed (e.g., in the
  41. * @code -[ALAdDisplayDelegate ad:wasHiddenIn:] @endcode callback).
  42. *
  43. * @warning You may pass a @c nil argument to @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode if you intend to use the synchronous
  44. * (@code +[ALIncentivizedIntrstitialAd isReadyForDisplay] @endcode) flow. This is <em>not</em> recommended; AppLovin <em>highly recommends</em> that
  45. * you use an ad load delegate.
  46. *
  47. * This method uses the shared instance, and will only work if you have set your SDK key in @code Info.plist @endcode.
  48. *
  49. * Note that AppLovin tries to pull down the next ad’s resources before you need it. Therefore, this method may complete immediately in many circumstances.
  50. *
  51. * @param adLoadDelegate The delegate to notify that preloading was completed. May be @c nil (see warning).
  52. */
  53. + (void)preloadAndNotify:(nullable id<ALAdLoadDelegate>)adLoadDelegate;
  54. /**
  55. * Whether or not an ad is currently ready on this object. You must first have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode in order
  56. * for this value to be meaningful.
  57. *
  58. * @warning It is highly recommended that you implement an asynchronous flow (using an @c ALAdLoadDelegate with
  59. * @code -[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode) rather than checking this property. This class does not contain a queue and can
  60. * hold only one preloaded ad at a time. Therefore, you should <em>not</em> simply call
  61. * @code -[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode) any time this method returns @c NO; it is important to invoke only one ad load —
  62. * then not invoke any further loads until the ad has been closed (e.g., in the @code -[ALAdDisplayDelegate ad:wasHiddenIn:] @endcode callback).
  63. *
  64. * @return @c YES if an ad has been loaded into this incentivized interstitial and is ready to display. @c NO otherwise.
  65. */
  66. + (BOOL)isReadyForDisplay;
  67. /**
  68. * Shows an incentivized interstitial over the current key window, by using the most recently pre-loaded ad.
  69. *
  70. * You must have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode before you call @code +[ALIncentivizedInterstitialAd show] @endcode.
  71. */
  72. + (void)show;
  73. /**
  74. * Shows an incentivized interstitial over the current key window, by using the most recently pre-loaded ad.
  75. *
  76. * You must have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode before you call @c showAndNotify.
  77. *
  78. * By using the @c ALAdRewardDelegate, you can verify with AppLovin servers that the video view is legitimate, as AppLovin will confirm whether
  79. * the specific ad was actually served. Then AppLovin will ping your server with a URL at which you can update the user’s balance. The Reward Validation
  80. * Delegate will tell you whether this service was able to reach AppLovin servers or not. If you receive a successful response, you should refresh the user’s
  81. * balance from your server. For more info, see the documentation.
  82. *
  83. * @param adRewardDelegate The reward delegate to notify upon validating reward authenticity with AppLovin.
  84. *
  85. * @see <a href="https://dash.applovin.com/documentation/mediation/s2s-rewarded-callback-api">MAX Integration Guide ⇒ MAX S2S Rewarded Callback API</a>
  86. */
  87. + (void)showAndNotify:(nullable id<ALAdRewardDelegate>)adRewardDelegate;
  88. #pragma mark - Integration, Instance Methods
  89. /**
  90. * Initializes an incentivized interstitial with a specific custom SDK.
  91. *
  92. * This is necessary if you use @code +[ALSdk sharedWithKey:] @endcode.
  93. *
  94. * @param sdk An SDK instance to use.
  95. */
  96. - (instancetype)initWithSdk:(ALSdk *)sdk;
  97. #pragma mark - Integration, zones
  98. /**
  99. * Initializes an incentivized interstitial with a zone.
  100. *
  101. * @param zoneIdentifier The identifier of the zone for which to load ads.
  102. */
  103. - (instancetype)initWithZoneIdentifier:(NSString *)zoneIdentifier;
  104. /**
  105. * Initializes an incentivized interstitial with a zone and a specific custom SDK.
  106. *
  107. * This is necessary if you use @code +[ALSdk sharedWithKey:] @endcode.
  108. *
  109. * @param zoneIdentifier The identifier of the zone for which to load ads.
  110. * @param sdk An SDK instance to use.
  111. */
  112. - (instancetype)initWithZoneIdentifier:(NSString *)zoneIdentifier sdk:(ALSdk *)sdk;
  113. /**
  114. * The zone identifier this incentivized ad was initialized with and is loading ads for, if any.
  115. */
  116. @property (nonatomic, copy, readonly, nullable) NSString *zoneIdentifier;
  117. /**
  118. * Pre-loads an incentivized interstitial, and notifies your provided Ad Load Delegate.
  119. *
  120. * Invoke this once to pre-load, then do not invoke it again until the ad has has been closed (e.g., in the
  121. * @code -[ALAdDisplayDelegate ad:wasHiddenIn:] @endcode callback).
  122. *
  123. * @warning You may pass a @c nil argument to @c preloadAndNotify if you intend to use the synchronous
  124. * (@code +[ALIncentivizedIntrstitialAd isReadyForDisplay] @endcode) flow. This is <em>not</em> recommended; AppLovin <em>highly recommends</em> that
  125. * you use an ad load delegate.
  126. *
  127. * Note that AppLovin tries to pull down the next ad’s resources before you need it. Therefore, this method may complete immediately in many circumstances.
  128. *
  129. * @param adLoadDelegate The delegate to notify that preloading was completed. May be @c nil (see warning).
  130. */
  131. - (void)preloadAndNotify:(nullable id<ALAdLoadDelegate>)adLoadDelegate;
  132. /**
  133. * Whether or not an ad is currently ready on this object. You must first have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode in order
  134. * for this value to be meaningful.
  135. *
  136. * @warning It is highly recommended that you implement an asynchronous flow (using an @c ALAdLoadDelegate with
  137. * @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode rather than checking this property. This class does not contain a queue and can
  138. * hold only one preloaded ad at a time. Therefore, you should <em>not</em> simply call
  139. * @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode any time this method returns @c NO; it is important to invoke only one ad load —
  140. * then not invoke any further loads until the ad has been closed (e.g., in the @code -[ALAdDisplayDelegate ad:wasHiddenIn:] @endcode callback).
  141. *
  142. * @return @c YES if an ad has been loaded into this incentivized interstitial and is ready to display. @c NO otherwise.
  143. */
  144. @property (atomic, readonly, getter=isReadyForDisplay) BOOL readyForDisplay;
  145. /**
  146. * Shows an incentivized interstitial over the current key window, by using the most recently pre-loaded ad.
  147. *
  148. * You must have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode before you call @c show.
  149. */
  150. - (void)show;
  151. /**
  152. * Shows an incentivized interstitial over the current key window, by using the most recently pre-loaded ad.
  153. *
  154. * You must have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode before you call @c showAndNotify.
  155. *
  156. * By using the @c ALAdRewardDelegate, you can verify with AppLovin servers that the video view is legitimate, as AppLovin will confirm whether
  157. * the specific ad was actually served. Then AppLovin will ping your server with a URL at which you can update the user’s balance. The Reward Validation
  158. * Delegate will tell you whether this service was able to reach AppLovin servers or not. If you receive a successful response, you should refresh the user’s
  159. * balance from your server. For more info, see the documentation.
  160. *
  161. * @param adRewardDelegate The reward delegate to notify upon validating reward authenticity with AppLovin.
  162. *
  163. * @see <a href="https://dash.applovin.com/documentation/mediation/s2s-rewarded-callback-api">MAX Integration Guide ⇒ MAX S2S Rewarded Callback API</a>
  164. */
  165. - (void)showAndNotify:(nullable id<ALAdRewardDelegate>)adRewardDelegate;
  166. /**
  167. * Shows an incentivized interstitial, by using the most recently pre-loaded ad.
  168. *
  169. * You must have called @code +[ALIncentivizedInterstitialAd preloadAndNotify:] @endcode before you call @c showAd.
  170. *
  171. * By using the @c ALAdRewardDelegate, you can verify with AppLovin servers that the video view is legitimate, as AppLovin will confirm whether
  172. * the specific ad was actually served. Then AppLovin will ping your server with a URL at which you can update the user’s balance. The Reward Validation
  173. * Delegate will tell you whether this service was able to reach AppLovin servers or not. If you receive a successful response, you should refresh the user’s
  174. * balance from your server. For more info, see the documentation.
  175. *
  176. * @param ad The ad to render into this incentivized ad.
  177. * @param adRewardDelegate The reward delegate to notify upon validating reward authenticity with AppLovin.
  178. *
  179. * @see <a href="https://dash.applovin.com/documentation/mediation/s2s-rewarded-callback-api">MAX Integration Guide ⇒ MAX S2S Rewarded Callback API</a>
  180. */
  181. - (void)showAd:(ALAd *)ad andNotify:(nullable id<ALAdRewardDelegate>)adRewardDelegate;
  182. /**
  183. * Sets extra info to pass to the SDK.
  184. *
  185. * @param key Parameter key.
  186. * @param value Parameter value.
  187. */
  188. - (void)setExtraInfoForKey:(NSString *)key value:(nullable id)value;
  189. - (instancetype)init __attribute__((unavailable("Use initWithSdk:, initWithZoneIdentifier:, or [ALIncentivizedInterstitialAd shared] instead.")));
  190. + (instancetype)new NS_UNAVAILABLE;
  191. @end
  192. NS_ASSUME_NONNULL_END