BUNativeExpressRewardedVideoAd.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // BUNativeExpressRewardedVideoAd.h
  3. // BUAdSDK
  4. //
  5. // Copyright © 2019 bytedance. All rights reserved.
  6. //
  7. #import <UIKit/UIKit.h>
  8. #import "BUAdSDKDefines.h"
  9. #import "BUMaterialMeta.h"
  10. #import "BUMopubAdMarkUpDelegate.h"
  11. @class BUNativeExpressRewardedVideoAd;
  12. @class BURewardedVideoModel;
  13. NS_ASSUME_NONNULL_BEGIN
  14. /// define the type of native express rewarded video Ad
  15. typedef NS_ENUM(NSUInteger, BUNativeExpressRewardedVideoAdType) {
  16. BUNativeExpressRewardedVideoAdTypeEndcard = 0, // video + endcard
  17. BUNativeExpressRewardedVideoAdTypeVideoPlayable = 1, // video + playable
  18. BUNativeExpressRewardedVideoAdTypePurePlayable = 2, // pure playable
  19. };
  20. @protocol BUNativeExpressRewardedVideoAdDelegate <NSObject>
  21. @optional
  22. /**
  23. This method is called when video ad material loaded successfully.
  24. */
  25. - (void)nativeExpressRewardedVideoAdDidLoad:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  26. /**
  27. This method is called when video ad materia failed to load.
  28. @param error : the reason of error
  29. */
  30. - (void)nativeExpressRewardedVideoAd:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error;
  31. /**
  32. this methods is to tell delegate the type of native express rewarded video Ad
  33. */
  34. - (void)nativeExpressRewardedVideoAdCallback:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd withType:(BUNativeExpressRewardedVideoAdType)nativeExpressVideoType;
  35. /**
  36. This method is called when cached successfully.
  37. For a better user experience, it is recommended to display video ads at this time.
  38. And you can call [BUNativeExpressRewardedVideoAd showAdFromRootViewController:].
  39. */
  40. - (void)nativeExpressRewardedVideoAdDidDownLoadVideo:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  41. /**
  42. This method is called when rendering a nativeExpressAdView successed.
  43. It will happen when ad is show.
  44. */
  45. - (void)nativeExpressRewardedVideoAdViewRenderSuccess:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  46. /**
  47. This method is called when a nativeExpressAdView failed to render.
  48. @param error : the reason of error
  49. */
  50. - (void)nativeExpressRewardedVideoAdViewRenderFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error;
  51. /**
  52. This method is called when video ad slot will be showing.
  53. */
  54. - (void)nativeExpressRewardedVideoAdWillVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  55. /**
  56. This method is called when video ad slot has been shown.
  57. */
  58. - (void)nativeExpressRewardedVideoAdDidVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  59. /**
  60. This method is called when video ad is about to close.
  61. */
  62. - (void)nativeExpressRewardedVideoAdWillClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  63. /**
  64. This method is called when video ad is closed.
  65. */
  66. - (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  67. /**
  68. This method is called when video ad is clicked.
  69. */
  70. - (void)nativeExpressRewardedVideoAdDidClick:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  71. /**
  72. This method is called when the user clicked skip button.
  73. */
  74. - (void)nativeExpressRewardedVideoAdDidClickSkip:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd;
  75. /**
  76. This method is called when video ad play completed or an error occurred.
  77. @param error : the reason of error
  78. */
  79. - (void)nativeExpressRewardedVideoAdDidPlayFinish:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error;
  80. /**
  81. Server verification which is requested asynchronously is succeeded. now include two v erify methods:
  82. 1. C2C need server verify 2. S2S don't need server verify
  83. @param verify :return YES when return value is 2000.
  84. */
  85. - (void)nativeExpressRewardedVideoAdServerRewardDidSucceed:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd verify:(BOOL)verify;
  86. /**
  87. Server verification which is requested asynchronously is failed.
  88. Return value is not 2000.
  89. */
  90. - (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd __attribute__((deprecated("Use nativeExpressRewardedVideoAdServerRewardDidFail: error: instead.")));
  91. /**
  92. Server verification which is requested asynchronously is failed.
  93. @param rewardedVideoAd express rewardVideo Ad
  94. @param error request error info
  95. */
  96. - (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error;
  97. /**
  98. This method is called when another controller has been closed.
  99. @param interactionType : open appstore in app or open the webpage or view video ad details page.
  100. */
  101. - (void)nativeExpressRewardedVideoAdDidCloseOtherController:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd interactionType:(BUInteractionType)interactionType;
  102. @end
  103. @interface BUNativeExpressRewardedVideoAd : NSObject <BUMopubAdMarkUpDelegate>
  104. @property (nonatomic, strong) BURewardedVideoModel *rewardedVideoModel;
  105. @property (nonatomic, weak, nullable) id<BUNativeExpressRewardedVideoAdDelegate> delegate;
  106. /// media configuration parameters.
  107. @property (nonatomic, copy, readonly) NSDictionary *mediaExt;
  108. /**
  109. Whether material is effective.
  110. Setted to YES when data is not empty and has not been displayed.
  111. Repeated display is not billed.
  112. */
  113. @property (nonatomic, getter=isAdValid, readonly) BOOL adValid __attribute__((deprecated("Use nativeExpressRewardedVideoAdDidLoad: instead.")));
  114. - (instancetype)initWithSlotID:(NSString *)slotID rewardedVideoModel:(BURewardedVideoModel *)model;
  115. /**
  116. Initializes Rewarded video ad with ad slot and frame.
  117. @param slot A object, through which you can pass in the reward unique identifier, ad type, and so on.
  118. @param model Rewarded video model.
  119. @return BUNativeExpressRewardedVideoAd
  120. */
  121. - (instancetype)initWithSlot:(BUAdSlot *)slot rewardedVideoModel:(BURewardedVideoModel *)model;
  122. - (void)loadAdData;
  123. /**
  124. Display video ad.
  125. @param rootViewController : root view controller for displaying ad.
  126. @return : whether it is successfully displayed.
  127. */
  128. - (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController;
  129. /**
  130. If ritSceneType is custom, you need to pass in the values for sceneDescirbe.
  131. @param ritSceneType : optional. Identifies a custom description of the presentation scenario.
  132. @param sceneDescirbe : optional. Identify the scene of presentation.
  133. */
  134. - (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController ritScene:(BURitSceneType)ritSceneType ritSceneDescribe:(NSString *_Nullable)sceneDescirbe;
  135. @end
  136. NS_ASSUME_NONNULL_END