MANativeAd.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //
  2. // MANativeAd.h
  3. // AppLovinSDK
  4. //
  5. // Created by Thomas So on 5/5/20.
  6. //
  7. #import <UIKit/UIKit.h>
  8. @class MAAdFormat;
  9. @class MANativeAdBuilder;
  10. @class MANativeAdImage;
  11. @class MANativeAdView;
  12. NS_ASSUME_NONNULL_BEGIN
  13. typedef void (^MANativeAdBuilderBlock) (MANativeAdBuilder *builder);
  14. @interface MANativeAdBuilder : NSObject
  15. @property (nonatomic, copy, nullable) NSString *title;
  16. @property (nonatomic, copy, nullable) NSString *advertiser;
  17. @property (nonatomic, copy, nullable) NSString *body;
  18. @property (nonatomic, copy, nullable) NSString *callToAction;
  19. @property (nonatomic, strong, nullable) MANativeAdImage *icon;
  20. @property (nonatomic, strong, nullable) MANativeAdImage *mainImage;
  21. @property (nonatomic, strong, nullable) UIView *iconView;
  22. @property (nonatomic, strong, nullable) UIView *optionsView;
  23. @property (nonatomic, strong, nullable) UIView *mediaView;
  24. @property (nonatomic, assign) CGFloat mediaContentAspectRatio;
  25. @property (nonatomic, strong, nullable) NSNumber *starRating;
  26. @end
  27. @interface MANativeAdImage : NSObject
  28. /**
  29. * The native ad image.
  30. */
  31. @property (nonatomic, strong, readonly, nullable) UIImage *image;
  32. /**
  33. * The native ad image URL.
  34. */
  35. @property (nonatomic, copy, readonly, nullable) NSURL *URL;
  36. - (instancetype)initWithImage:(UIImage *)image;
  37. - (instancetype)initWithURL:(NSURL *)URL;
  38. - (instancetype)init NS_UNAVAILABLE;
  39. @end
  40. /**
  41. * Represents a native ad to be rendered for an instance of a @c MAAd.
  42. */
  43. @interface MANativeAd : NSObject
  44. /**
  45. * The native ad format.
  46. */
  47. @property (nonatomic, weak, readonly) MAAdFormat *format;
  48. /**
  49. * The native ad title text.
  50. */
  51. @property (nonatomic, copy, readonly, nullable) NSString *title;
  52. /**
  53. * The native ad advertiser text.
  54. */
  55. @property (nonatomic, copy, readonly, nullable) NSString *advertiser;
  56. /**
  57. * The native ad body text.
  58. */
  59. @property (nonatomic, copy, readonly, nullable) NSString *body;
  60. /**
  61. * The native ad CTA button text.
  62. */
  63. @property (nonatomic, copy, readonly, nullable) NSString *callToAction;
  64. /**
  65. * The native ad icon image.
  66. */
  67. @property (nonatomic, strong, readonly, nullable) MANativeAdImage *icon;
  68. /**
  69. * The native ad icon image view.
  70. *
  71. * This is only used for banners using native APIs. Native ads must provide a `MANativeAdImage` instead.
  72. */
  73. @property (nonatomic, strong, readonly, nullable) UIView *iconView;
  74. /**
  75. * The native ad options view.
  76. */
  77. @property (nonatomic, strong, readonly, nullable) UIView *optionsView;
  78. /**
  79. * The native ad media view.
  80. */
  81. @property (nonatomic, strong, readonly, nullable) UIView *mediaView;
  82. /**
  83. * The native ad main image (cover image). May or may not be a locally cached file:// resource file.
  84. *
  85. * Please make sure you continue to render your native ad using @c MANativeAdLoader so impression tracking is not affected.
  86. *
  87. * Supported adapter versions:
  88. *
  89. * BidMachine v1.9.4.1.1
  90. * Google Ad Manager v9.6.0.1
  91. * Google AdMob v9.6.0.2
  92. * Mintegral v7.1.7.0.2
  93. * myTarget v5.15.2.1
  94. * Pangle v4.5.2.4.1
  95. * Smaato v21.7.6.1
  96. */
  97. @property (nonatomic, strong, readonly, nullable) MANativeAdImage *mainImage;
  98. /**
  99. * The aspect ratio for the media view if provided by the network. Otherwise returns 0.0f.
  100. */
  101. @property (nonatomic, assign, readonly) CGFloat mediaContentAspectRatio;
  102. /**
  103. * The star rating of the native ad in the [0.0, 5.0] range if provided by the network. Otherwise returns @c nil.
  104. */
  105. @property (nonatomic, strong, readonly, nullable) NSNumber *starRating;
  106. /**
  107. * Whether or not the ad is expired.
  108. */
  109. @property (nonatomic, assign, readonly, getter=isExpired) BOOL expired;
  110. /**
  111. * This method is called before the ad view is returned to the publisher.
  112. * The adapters should override this method to register the rendered native ad view and make sure that the view is interactable.
  113. *
  114. * @param nativeAdView a rendered native ad view.
  115. */
  116. - (void)prepareViewForInteraction:(MANativeAdView *)nativeAdView __deprecated_msg("This method has been deprecated and will be removed in a future SDK version. Please use -[MANativeAd prepareForInteractionClickableViews:withContainer:] instead.");
  117. /**
  118. * *********************
  119. * AVAILABLE IN v11.5.2+
  120. * *********************
  121. *
  122. * This method is called before the ad view is returned to the publisher.
  123. * The adapters should override this method to register the rendered native ad view and make sure that the view is interactable.
  124. *
  125. * @param clickableViews The clickable views for the native ad.
  126. * @param container The container for the native ad.
  127. *
  128. * @return @c YES if the call has been successfully handled by a subclass of @c MANativeAd.
  129. */
  130. - (BOOL)prepareForInteractionClickableViews:(NSArray<UIView *> *)clickableViews withContainer:(UIView *)container;
  131. /**
  132. * Whether or not to run the @code -[MANativeAd prepareForInteractionClickableViews:withContainer:] @endcode call on the main thread or background thread.
  133. *
  134. * @return @c YES to run the operation on the main thread, @c NO to run the operation on a background thread. Defaults to @c YES.
  135. */
  136. - (BOOL)shouldPrepareViewForInteractionOnMainThread;
  137. /**
  138. * *********************
  139. * AVAILABLE IN v11.6.0+
  140. * *********************
  141. *
  142. * Whether or not container clickability is supported.
  143. */
  144. - (BOOL)isContainerClickable;
  145. /**
  146. * For supported mediated SDKs, manually invoke a click.
  147. */
  148. - (void)performClick;
  149. - (instancetype)initWithFormat:(MAAdFormat *)format builderBlock:(NS_NOESCAPE MANativeAdBuilderBlock)builderBlock;
  150. - (instancetype)init NS_UNAVAILABLE;
  151. @end
  152. NS_ASSUME_NONNULL_END