MAAdapter.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // MAAdapter.h
  3. // AppLovinSDK
  4. //
  5. // Created by Thomas So on 8/10/18.
  6. // Copyright © 2019 AppLovin Corporation. All rights reserved.
  7. //
  8. #import <AppLovinSDK/MAAdapterInitializationParameters.h>
  9. #import <AppLovinSDK/MAAdFormat.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. /**
  12. * An enum describing the adapter's initialization status.
  13. */
  14. typedef NS_ENUM(NSInteger, MAAdapterInitializationStatus)
  15. {
  16. /**
  17. * The adapter is not initialized. Note: networks need to be enabled for an ad unit id to be initialized.
  18. */
  19. MAAdapterInitializationStatusAdapterNotInitialized = -4,
  20. /**
  21. * The 3rd-party SDK does not have an initialization callback with status.
  22. */
  23. MAAdapterInitializationStatusDoesNotApply = -3,
  24. /**
  25. * The 3rd-party SDK is currently initializing.
  26. */
  27. MAAdapterInitializationStatusInitializing = -2,
  28. /**
  29. * The 3rd-party SDK explicitly initialized, but without a status.
  30. */
  31. MAAdapterInitializationStatusInitializedUnknown = -1,
  32. /**
  33. * The 3rd-party SDK initialization failed.
  34. */
  35. MAAdapterInitializationStatusInitializedFailure = 0,
  36. /**
  37. * The 3rd-party SDK initialization was successful.
  38. */
  39. MAAdapterInitializationStatusInitializedSuccess = 1
  40. };
  41. /**
  42. * This protocol defines a mediation adapter which wraps a third-party ad SDK and will be used by AppLovin to load and display ads.
  43. */
  44. @protocol MAAdapter <NSObject>
  45. /**
  46. * Initialize current adapter. This method will be called at the beginning of the adapter lifecycle.
  47. *
  48. * @param parameters Parameters passed from the server.
  49. * @param completionHandler Completion block to be called when the 3rd-party SDK finishes initialization, whether or not it was successful.
  50. */
  51. - (void)initializeWithParameters:(id<MAAdapterInitializationParameters>)parameters withCompletionHandler:(void(^)(void))completionHandler;
  52. /**
  53. * The version of the third-party SDK.
  54. */
  55. @property (nonatomic, copy, readonly) NSString *SDKVersion;
  56. /**
  57. * The version of this adapter.
  58. */
  59. @property (nonatomic, copy, readonly) NSString *adapterVersion;
  60. /**
  61. * Whether or not this adapter is a beta version.
  62. */
  63. @property (nonatomic, assign, readonly, getter=isBeta) BOOL beta;
  64. /**
  65. * *********************
  66. * AVAILABLE IN v11.9.0+
  67. * *********************
  68. * <p>
  69. * Whether or not to initialize the third-party SDK on main thread.
  70. *
  71. * @return @c 1 if the SDK should be initialized on main thread. @c nil if we should fallback to using the adapter spec level setting.
  72. */
  73. - (nullable NSNumber *)shouldInitializeOnMainThread;
  74. /**
  75. * *********************
  76. * AVAILABLE IN v11.9.0+
  77. * *********************
  78. * <p>
  79. * Whether or not to collect signals on main thread.
  80. *
  81. * @return @c 1 if the SDK should collect signals on main thread. @c nil if we should fallback to using the adapter spec level setting.
  82. */
  83. - (nullable NSNumber *)shouldCollectSignalsOnMainThread;
  84. /**
  85. * *********************
  86. * AVAILABLE IN v11.9.0+
  87. * *********************
  88. * <p>
  89. * Whether or not to load ads on main thread.
  90. *
  91. * @param adFormat The @c MAAdFormat for which to check if we should load on main thread.
  92. *
  93. * @return @c 1 if the given ad format should be loaded on main thread. @c nil if we should fallback to using the adapter spec level setting.
  94. */
  95. - (nullable NSNumber *)shouldLoadAdsOnMainThreadForAdFormat:(MAAdFormat *)adFormat;
  96. /**
  97. * *********************
  98. * AVAILABLE IN v11.9.0+
  99. * *********************
  100. * <p>
  101. * Whether or not to show ads on main thread.
  102. *
  103. * @param adFormat The @c MAAdFormat for which to check if we should show on main thread.
  104. *
  105. * @return @c 1 if the given ad format should be loaded on main thread. @c nil if we should fallback to using the adapter spec level setting.
  106. */
  107. - (nullable NSNumber *)shouldShowAdsOnMainThreadForAdFormat:(MAAdFormat *)adFormat;
  108. /**
  109. * This method is called when an ad associated with this adapter should be destroyed. Necessary cleanup should be performed here.
  110. */
  111. - (void)destroy;
  112. @optional
  113. /**
  114. * Initialize current adapter. This method will be called at the beginning of the adapter lifecycle.
  115. *
  116. * @param parameters Parameters passed from the server.
  117. * @param completionHandler Completion block to be called when the 3rd-party SDK finishes initialization, with the initialization status passed in.
  118. */
  119. - (void)initializeWithParameters:(id<MAAdapterInitializationParameters>)parameters completionHandler:(void(^)(MAAdapterInitializationStatus initializationStatus, NSString *_Nullable errorMessage))completionHandler;
  120. @end
  121. NS_ASSUME_NONNULL_END