BUNativeAd.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. // BUNativeAd.h
  3. // BUAdSDK
  4. //
  5. // Copyright © 2017 bytedance. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import <UIKit/UIKit.h>
  9. #import "BUAdSlot.h"
  10. #import "BUMaterialMeta.h"
  11. #import "BUVideoAdView.h"
  12. #import "BUMopubAdMarkUpDelegate.h"
  13. @protocol BUNativeAdDelegate;
  14. NS_ASSUME_NONNULL_BEGIN
  15. /**
  16. Abstract ad slot containing ad data loading, response callbacks.
  17. BUNativeAd currently supports native ads.
  18. Native ads include in-feed ad (multiple ads, image + video), general native ad (single ad, image + video), native banner ad, and native interstitial ad.
  19. Support interstitial ad, banner ad, splash ad, rewarded video ad, full-screen video ad.
  20. */
  21. @interface BUNativeAd : NSObject <BUMopubAdMarkUpDelegate>
  22. /**
  23. Ad slot description.
  24. */
  25. @property (nonatomic, strong, readwrite, nullable) BUAdSlot *adslot;
  26. /**
  27. Ad slot material.
  28. */
  29. @property (atomic, strong, readonly, nullable) BUMaterialMeta *data;
  30. /**
  31. The delegate for receiving state change messages.
  32. The delegate is not limited to viewcontroller.
  33. The delegate can be set to any object which conforming to <BUNativeAdDelegate>.
  34. */
  35. @property (nonatomic, weak, readwrite, nullable) id<BUNativeAdDelegate> delegate;
  36. /**
  37. required.
  38. Root view controller for handling ad actions.
  39. Action method includes is 'presentViewController'.
  40. */
  41. @property (nonatomic, weak, readwrite) UIViewController *rootViewController;
  42. /**
  43. Initializes native ad with ad slot.
  44. @param slot : ad slot description.
  45. including slotID,adType,adPosition,etc.
  46. @return BUNativeAd
  47. */
  48. - (instancetype)initWithSlot:(BUAdSlot *)slot;
  49. /**
  50. Register clickable views in native ads view.
  51. Interaction types can be configured on TikTok Audience Network.
  52. Interaction types include view video ad details page, make a call, send email, download the app, open the webpage using a browser,open the webpage within the app, etc.
  53. @param containerView : required.
  54. container view of the native ad.
  55. @param clickableViews : optional.
  56. Array of views that are clickable.
  57. */
  58. - (void)registerContainer:(__kindof UIView *)containerView
  59. withClickableViews:(NSArray<__kindof UIView *> *_Nullable)clickableViews;
  60. /**
  61. Unregister ad view from the native ad.
  62. */
  63. - (void)unregisterView;
  64. /**
  65. Actively request nativeAd datas.
  66. */
  67. - (void)loadAdData;
  68. @end
  69. @protocol BUNativeAdDelegate <NSObject>
  70. @optional
  71. /**
  72. This method is called when native ad material loaded successfully. This method will be deprecated. Use nativeAdDidLoad:view: instead
  73. */
  74. - (void)nativeAdDidLoad:(BUNativeAd *)nativeAd;
  75. /**
  76. This method is called when native ad material loaded successfully.
  77. */
  78. - (void)nativeAdDidLoad:(BUNativeAd *)nativeAd view:(UIView *_Nullable)view;
  79. /**
  80. This method is called when native ad materia failed to load.
  81. @param error : the reason of error
  82. */
  83. - (void)nativeAd:(BUNativeAd *)nativeAd didFailWithError:(NSError *_Nullable)error;
  84. /**
  85. This method is called when native ad slot has been shown.
  86. */
  87. - (void)nativeAdDidBecomeVisible:(BUNativeAd *)nativeAd;
  88. /**
  89. This method is called when another controller has been closed.
  90. @param interactionType : open appstore in app or open the webpage or view video ad details page.
  91. */
  92. - (void)nativeAdDidCloseOtherController:(BUNativeAd *)nativeAd interactionType:(BUInteractionType)interactionType;
  93. /**
  94. This method is called when native ad is clicked.
  95. */
  96. - (void)nativeAdDidClick:(BUNativeAd *)nativeAd withView:(UIView *_Nullable)view;
  97. /**
  98. This method is called when the user clicked dislike reasons.
  99. Only used for dislikeButton in BUNativeAdRelatedView.h
  100. @param filterWords : reasons for dislike
  101. */
  102. - (void)nativeAd:(BUNativeAd *_Nullable)nativeAd dislikeWithReason:(NSArray<BUDislikeWords *> *_Nullable)filterWords;
  103. /**
  104. This method is called when the Ad view container is forced to be removed.
  105. @param nativeAd : Ad material
  106. @param adContainerView : Ad view container
  107. */
  108. - (void)nativeAd:(BUNativeAd *_Nullable)nativeAd adContainerViewDidRemoved:(UIView *)adContainerView;
  109. @end
  110. NS_ASSUME_NONNULL_END