MaxSdkAndroid.cs 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using AppLovinMax.ThirdParty.MiniJson;
  5. #if UNITY_ANDROID
  6. /// <summary>
  7. /// Android AppLovin MAX Unity Plugin implementation
  8. /// </summary>
  9. public class MaxSdkAndroid : MaxSdkBase
  10. {
  11. private static readonly AndroidJavaClass MaxUnityPluginClass =
  12. new AndroidJavaClass("com.applovin.mediation.unity.MaxUnityPlugin");
  13. private static readonly BackgroundCallbackProxy BackgroundCallback = new BackgroundCallbackProxy();
  14. static MaxSdkAndroid()
  15. {
  16. InitializeEventExecutor();
  17. MaxUnityPluginClass.CallStatic("setBackgroundCallback", BackgroundCallback);
  18. }
  19. #region Initialization
  20. /// <summary>
  21. /// Initialize the default instance of AppLovin SDK.
  22. ///
  23. /// Please make sure that application's Android manifest or Info.plist includes the AppLovin SDK key.
  24. /// <param name="adUnitIds">
  25. /// OPTIONAL: Set the MAX ad unit ids to be used for this instance of the SDK. 3rd-party SDKs will be initialized with the credentials configured for these ad unit ids.
  26. /// This should only be used if you have different sets of ad unit ids / credentials for the same package name.</param>
  27. /// </summary>
  28. public static void InitializeSdk(string[] adUnitIds = null)
  29. {
  30. var serializedAdUnitIds = (adUnitIds != null) ? string.Join(",", adUnitIds) : "";
  31. MaxUnityPluginClass.CallStatic("initializeSdk", serializedAdUnitIds, GenerateMetaData());
  32. }
  33. /// <summary>
  34. /// Check if the SDK has been initialized
  35. /// </summary>
  36. /// <returns>True if SDK has been initialized</returns>
  37. public static bool IsInitialized()
  38. {
  39. return MaxUnityPluginClass.CallStatic<bool>("isInitialized");
  40. }
  41. #endregion
  42. #region User Info
  43. /// <summary>
  44. /// Set an identifier for the current user. This identifier will be tied to SDK events and our optional S2S postbacks.
  45. ///
  46. /// If you're using reward validation, you can optionally set an identifier to be included with currency validation postbacks.
  47. /// For example, a username or email. We'll include this in the postback when we ping your currency endpoint from our server.
  48. /// </summary>
  49. ///
  50. /// <param name="userId">The user identifier to be set. Must not be null.</param>
  51. public static void SetUserId(string userId)
  52. {
  53. MaxUnityPluginClass.CallStatic("setUserId", userId);
  54. }
  55. /// <summary>
  56. /// Set the <see cref="MaxSegmentCollection"/>.
  57. /// </summary>
  58. /// <param name="segmentCollection"> The segment collection to be set. Must not be {@code null}</param>
  59. public static void SetSegmentCollection(MaxSegmentCollection segmentCollection)
  60. {
  61. MaxUnityPluginClass.CallStatic("setSegmentCollection", JsonUtility.ToJson(segmentCollection));
  62. }
  63. #endregion
  64. #region MAX
  65. /// <summary>
  66. /// Returns the list of available mediation networks.
  67. ///
  68. /// Please call this method after the SDK has initialized.
  69. /// </summary>
  70. public static List<MediatedNetworkInfo> GetAvailableMediatedNetworks()
  71. {
  72. var serializedNetworks = MaxUnityPluginClass.CallStatic<string>("getAvailableMediatedNetworks");
  73. return MaxSdkUtils.PropsStringsToList<MediatedNetworkInfo>(serializedNetworks);
  74. }
  75. /// <summary>
  76. /// Present the mediation debugger UI.
  77. /// This debugger tool provides the status of your integration for each third-party ad network.
  78. ///
  79. /// Please call this method after the SDK has initialized.
  80. /// </summary>
  81. public static void ShowMediationDebugger()
  82. {
  83. MaxUnityPluginClass.CallStatic("showMediationDebugger");
  84. }
  85. /// <summary>
  86. /// Present the creative debugger UI.
  87. /// This debugger tool provides information for recently displayed ads.
  88. ///
  89. /// Please call this method after the SDK has initialized.
  90. /// </summary>
  91. public static void ShowCreativeDebugger()
  92. {
  93. MaxUnityPluginClass.CallStatic("showCreativeDebugger");
  94. }
  95. /// <summary>
  96. /// Returns the arbitrary ad value for a given ad unit identifier with key. Returns null if no ad is loaded.
  97. /// </summary>
  98. /// <param name="adUnitIdentifier">Ad unit identifier for which to get the ad value for. Must not be null.</param>
  99. /// <param name="key">Ad value key. Must not be null.</param>
  100. /// <returns>Arbitrary ad value for a given key, or null if no ad is loaded.</returns>
  101. public static string GetAdValue(string adUnitIdentifier, string key)
  102. {
  103. var value = MaxUnityPluginClass.CallStatic<string>("getAdValue", adUnitIdentifier, key);
  104. if (string.IsNullOrEmpty(value)) return null;
  105. return value;
  106. }
  107. #endregion
  108. #region Privacy
  109. /// <summary>
  110. /// Get the SDK configuration for this user.
  111. ///
  112. /// Note: This method should be called only after SDK has been initialized.
  113. /// </summary>
  114. public static SdkConfiguration GetSdkConfiguration()
  115. {
  116. var sdkConfigurationStr = MaxUnityPluginClass.CallStatic<string>("getSdkConfiguration");
  117. var sdkConfigurationDict = Json.Deserialize(sdkConfigurationStr) as Dictionary<string, object>;
  118. return SdkConfiguration.Create(sdkConfigurationDict);
  119. }
  120. /// <summary>
  121. /// Set whether or not user has provided consent for information sharing with AppLovin and other providers.
  122. /// </summary>
  123. /// <param name="hasUserConsent"><c>true</c> if the user has provided consent for information sharing with AppLovin. <c>false</c> by default.</param>
  124. public static void SetHasUserConsent(bool hasUserConsent)
  125. {
  126. MaxUnityPluginClass.CallStatic("setHasUserConsent", hasUserConsent);
  127. }
  128. /// <summary>
  129. /// Check if user has provided consent for information sharing with AppLovin and other providers.
  130. /// </summary>
  131. /// <returns><c>true</c> if user has provided consent for information sharing. <c>false</c> if the user declined to share information or the consent value has not been set. See <see cref="IsUserConsentSet">IsUserConsentSet</see>.</returns>
  132. public static bool HasUserConsent()
  133. {
  134. return MaxUnityPluginClass.CallStatic<bool>("hasUserConsent");
  135. }
  136. /// <summary>
  137. /// Check if user has set consent for information sharing.
  138. /// </summary>
  139. /// <returns><c>true</c> if user has set a value of consent for information sharing.</returns>
  140. public static bool IsUserConsentSet()
  141. {
  142. return MaxUnityPluginClass.CallStatic<bool>("isUserConsentSet");
  143. }
  144. /// <summary>
  145. /// Set whether or not user has opted out of the sale of their personal information.
  146. /// </summary>
  147. /// <param name="doNotSell"><c>true</c> if the user has opted out of the sale of their personal information.</param>
  148. public static void SetDoNotSell(bool doNotSell)
  149. {
  150. MaxUnityPluginClass.CallStatic("setDoNotSell", doNotSell);
  151. }
  152. /// <summary>
  153. /// Check if the user has opted out of the sale of their personal information.
  154. /// </summary>
  155. /// <returns><c>true</c> if the user has opted out of the sale of their personal information. <c>false</c> if the user opted in to the sell of their personal information or the value has not been set. See <see cref="IsDoNotSellSet">IsDoNotSellSet</see>.</returns>
  156. public static bool IsDoNotSell()
  157. {
  158. return MaxUnityPluginClass.CallStatic<bool>("isDoNotSell");
  159. }
  160. /// <summary>
  161. /// Check if the user has set the option to sell their personal information.
  162. /// </summary>
  163. /// <returns><c>true</c> if user has chosen an option to sell their personal information.</returns>
  164. public static bool IsDoNotSellSet()
  165. {
  166. return MaxUnityPluginClass.CallStatic<bool>("isDoNotSellSet");
  167. }
  168. #endregion
  169. #region Banners
  170. /// <summary>
  171. /// Create a new banner.
  172. /// </summary>
  173. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to create. Must not be null.</param>
  174. /// <param name="configuration">The configuration for the banner</param>
  175. public static void CreateBanner(string adUnitIdentifier, AdViewConfiguration configuration)
  176. {
  177. ValidateAdUnitIdentifier(adUnitIdentifier, "create banner");
  178. if (configuration.UseCoordinates)
  179. {
  180. MaxUnityPluginClass.CallStatic("createBanner", adUnitIdentifier, configuration.XCoordinate, configuration.YCoordinate, configuration.IsAdaptive);
  181. }
  182. else
  183. {
  184. MaxUnityPluginClass.CallStatic("createBanner", adUnitIdentifier, configuration.Position.ToSnakeCaseString(), configuration.IsAdaptive);
  185. }
  186. }
  187. /// <summary>
  188. /// Load a new banner ad.
  189. /// NOTE: The <see cref="CreateBanner()"/> method loads the first banner ad and initiates an automated banner refresh process.
  190. /// You only need to call this method if you pause banner refresh.
  191. /// </summary>
  192. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to load. Must not be null.</param>
  193. public static void LoadBanner(string adUnitIdentifier)
  194. {
  195. ValidateAdUnitIdentifier(adUnitIdentifier, "load banner");
  196. MaxUnityPluginClass.CallStatic("loadBanner", adUnitIdentifier);
  197. }
  198. /// <summary>
  199. /// Set the banner placement for an ad unit identifier to tie the future ad events to.
  200. /// </summary>
  201. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set the placement for. Must not be null.</param>
  202. /// <param name="placement">Placement to set</param>
  203. public static void SetBannerPlacement(string adUnitIdentifier, string placement)
  204. {
  205. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner placement");
  206. MaxUnityPluginClass.CallStatic("setBannerPlacement", adUnitIdentifier, placement);
  207. }
  208. /// <summary>
  209. /// Starts or resumes auto-refreshing of the banner for the given ad unit identifier.
  210. /// </summary>
  211. /// <param name="adUnitIdentifier">Ad unit identifier of the banner for which to start auto-refresh. Must not be null.</param>
  212. public static void StartBannerAutoRefresh(string adUnitIdentifier)
  213. {
  214. ValidateAdUnitIdentifier(adUnitIdentifier, "start banner auto-refresh");
  215. MaxUnityPluginClass.CallStatic("startBannerAutoRefresh", adUnitIdentifier);
  216. }
  217. /// <summary>
  218. /// Pauses auto-refreshing of the banner for the given ad unit identifier.
  219. /// </summary>
  220. /// <param name="adUnitIdentifier">Ad unit identifier of the banner for which to stop auto-refresh. Must not be null.</param>
  221. public static void StopBannerAutoRefresh(string adUnitIdentifier)
  222. {
  223. ValidateAdUnitIdentifier(adUnitIdentifier, "stop banner auto-refresh");
  224. MaxUnityPluginClass.CallStatic("stopBannerAutoRefresh", adUnitIdentifier);
  225. }
  226. /// <summary>
  227. /// Updates the position of the banner to the new position provided.
  228. /// </summary>
  229. /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to update the position. Must not be null.</param>
  230. /// <param name="bannerPosition">A new position for the banner. Must not be null.</param>
  231. public static void UpdateBannerPosition(string adUnitIdentifier, AdViewPosition bannerPosition)
  232. {
  233. ValidateAdUnitIdentifier(adUnitIdentifier, "update banner position");
  234. MaxUnityPluginClass.CallStatic("updateBannerPosition", adUnitIdentifier, bannerPosition.ToSnakeCaseString());
  235. }
  236. /// <summary>
  237. /// Updates the position of the banner to the new coordinates provided.
  238. /// </summary>
  239. /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to update the position. Must not be null.</param>
  240. /// <param name="x">The X coordinate (horizontal position) of the banner relative to the top left corner of the screen.</param>
  241. /// <param name="y">The Y coordinate (vertical position) of the banner relative to the top left corner of the screen.</param>
  242. /// <seealso cref="GetBannerLayout">
  243. /// The banner is placed within the safe area of the screen. You can use this to get the absolute position of the banner on screen.
  244. /// </seealso>
  245. public static void UpdateBannerPosition(string adUnitIdentifier, float x, float y)
  246. {
  247. ValidateAdUnitIdentifier(adUnitIdentifier, "update banner position");
  248. MaxUnityPluginClass.CallStatic("updateBannerPosition", adUnitIdentifier, x, y);
  249. }
  250. /// <summary>
  251. /// Overrides the width of the banner in dp.
  252. /// </summary>
  253. /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to override the width for. Must not be null.</param>
  254. /// <param name="width">The desired width of the banner in dp</param>
  255. public static void SetBannerWidth(string adUnitIdentifier, float width)
  256. {
  257. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner width");
  258. MaxUnityPluginClass.CallStatic("setBannerWidth", adUnitIdentifier, width);
  259. }
  260. /// <summary>
  261. /// Show banner at a position determined by the 'CreateBanner' call.
  262. /// </summary>
  263. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to show. Must not be null.</param>
  264. public static void ShowBanner(string adUnitIdentifier)
  265. {
  266. ValidateAdUnitIdentifier(adUnitIdentifier, "show banner");
  267. MaxUnityPluginClass.CallStatic("showBanner", adUnitIdentifier);
  268. }
  269. /// <summary>
  270. /// Remove banner from the ad view and destroy it.
  271. /// </summary>
  272. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to destroy. Must not be null.</param>
  273. public static void DestroyBanner(string adUnitIdentifier)
  274. {
  275. ValidateAdUnitIdentifier(adUnitIdentifier, "destroy banner");
  276. MaxUnityPluginClass.CallStatic("destroyBanner", adUnitIdentifier);
  277. }
  278. /// <summary>
  279. /// Hide banner.
  280. /// </summary>
  281. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to hide. Must not be null.</param>
  282. public static void HideBanner(string adUnitIdentifier)
  283. {
  284. ValidateAdUnitIdentifier(adUnitIdentifier, "hide banner");
  285. MaxUnityPluginClass.CallStatic("hideBanner", adUnitIdentifier);
  286. }
  287. /// <summary>
  288. /// Set non-transparent background color for banners to be fully functional.
  289. /// </summary>
  290. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set background color for. Must not be null.</param>
  291. /// <param name="color">A background color to set for the ad. Must not be null.</param>
  292. public static void SetBannerBackgroundColor(string adUnitIdentifier, Color color)
  293. {
  294. ValidateAdUnitIdentifier(adUnitIdentifier, "set background color");
  295. MaxUnityPluginClass.CallStatic("setBannerBackgroundColor", adUnitIdentifier, MaxSdkUtils.ParseColor(color));
  296. }
  297. /// <summary>
  298. /// Set an extra parameter for the banner ad.
  299. /// </summary>
  300. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set the extra parameter for. Must not be null.</param>
  301. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  302. /// <param name="value">The value for the extra parameter.</param>
  303. public static void SetBannerExtraParameter(string adUnitIdentifier, string key, string value)
  304. {
  305. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner extra parameter");
  306. MaxUnityPluginClass.CallStatic("setBannerExtraParameter", adUnitIdentifier, key, value);
  307. }
  308. /// <summary>
  309. /// Set a local extra parameter for the banner ad.
  310. /// </summary>
  311. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set the local extra parameter for. Must not be null.</param>
  312. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  313. /// <param name="value">The value for the extra parameter. Accepts the following types: <see cref="AndroidJavaObject"/>, <c>null</c>, <c>IList</c>, <c>IDictionary</c>, <c>string</c>, primitive types</param>
  314. public static void SetBannerLocalExtraParameter(string adUnitIdentifier, string key, object value)
  315. {
  316. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner local extra parameter");
  317. if (value == null || value is AndroidJavaObject)
  318. {
  319. MaxUnityPluginClass.CallStatic("setBannerLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  320. }
  321. else
  322. {
  323. MaxUnityPluginClass.CallStatic("setBannerLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  324. }
  325. }
  326. /// <summary>
  327. /// The custom data to tie the showing banner ad to, for ILRD and rewarded postbacks via the <c>{CUSTOM_DATA}</c> macro. Maximum size is 8KB.
  328. /// </summary>
  329. /// <param name="adUnitIdentifier">Banner ad unit identifier of the banner to set the custom data for. Must not be null.</param>
  330. /// <param name="customData">The custom data to be set.</param>
  331. public static void SetBannerCustomData(string adUnitIdentifier, string customData)
  332. {
  333. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner custom data");
  334. MaxUnityPluginClass.CallStatic("setBannerCustomData", adUnitIdentifier, customData);
  335. }
  336. /// <summary>
  337. /// The banner position on the screen. When setting the banner position via <see cref="CreateBanner(string, float, float)"/> or <see cref="UpdateBannerPosition(string, float, float)"/>,
  338. /// the banner is placed within the safe area of the screen. This returns the absolute position of the banner on screen.
  339. /// </summary>
  340. /// <param name="adUnitIdentifier">Ad unit identifier of the banner for which to get the position on screen. Must not be null.</param>
  341. /// <returns>A <see cref="Rect"/> representing the banner position on screen.</returns>
  342. public static Rect GetBannerLayout(string adUnitIdentifier)
  343. {
  344. ValidateAdUnitIdentifier(adUnitIdentifier, "get banner layout");
  345. var positionRect = MaxUnityPluginClass.CallStatic<string>("getBannerLayout", adUnitIdentifier);
  346. return GetRectFromString(positionRect);
  347. }
  348. #endregion
  349. #region MRECs
  350. /// <summary>
  351. /// Create a new MREC.
  352. /// </summary>
  353. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to create. Must not be null.</param>
  354. /// <param name="configuration">The configuration for the MREC.</param>
  355. public static void CreateMRec(string adUnitIdentifier, AdViewConfiguration configuration)
  356. {
  357. ValidateAdUnitIdentifier(adUnitIdentifier, "create MREC");
  358. if (configuration.UseCoordinates)
  359. {
  360. MaxUnityPluginClass.CallStatic("createMRec", adUnitIdentifier, configuration.XCoordinate, configuration.YCoordinate);
  361. }
  362. else
  363. {
  364. MaxUnityPluginClass.CallStatic("createMRec", adUnitIdentifier, configuration.Position.ToSnakeCaseString());
  365. }
  366. }
  367. /// <summary>
  368. /// Load a new MREC ad.
  369. /// NOTE: The <see cref="CreateMRec()"/> method loads the first MREC ad and initiates an automated MREC refresh process.
  370. /// You only need to call this method if you pause MREC refresh.
  371. /// </summary>
  372. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to load. Must not be null.</param>
  373. public static void LoadMRec(string adUnitIdentifier)
  374. {
  375. ValidateAdUnitIdentifier(adUnitIdentifier, "load MREC");
  376. MaxUnityPluginClass.CallStatic("loadMRec", adUnitIdentifier);
  377. }
  378. /// <summary>
  379. /// Set the MREC placement for an ad unit identifier to tie the future ad events to.
  380. /// </summary>
  381. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to set the placement for. Must not be null.</param>
  382. /// <param name="placement">Placement to set</param>
  383. public static void SetMRecPlacement(string adUnitIdentifier, string placement)
  384. {
  385. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC placement");
  386. MaxUnityPluginClass.CallStatic("setMRecPlacement", adUnitIdentifier, placement);
  387. }
  388. /// <summary>
  389. /// Starts or resumes auto-refreshing of the MREC for the given ad unit identifier.
  390. /// </summary>
  391. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC for which to start auto-refresh. Must not be null.</param>
  392. public static void StartMRecAutoRefresh(string adUnitIdentifier)
  393. {
  394. ValidateAdUnitIdentifier(adUnitIdentifier, "start MREC auto-refresh");
  395. MaxUnityPluginClass.CallStatic("startMRecAutoRefresh", adUnitIdentifier);
  396. }
  397. /// <summary>
  398. /// Pauses auto-refreshing of the MREC for the given ad unit identifier.
  399. /// </summary>
  400. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC for which to stop auto-refresh. Must not be null.</param>
  401. public static void StopMRecAutoRefresh(string adUnitIdentifier)
  402. {
  403. ValidateAdUnitIdentifier(adUnitIdentifier, "stop MREC auto-refresh");
  404. MaxUnityPluginClass.CallStatic("stopMRecAutoRefresh", adUnitIdentifier);
  405. }
  406. /// <summary>
  407. /// Updates the position of the MREC to the new position provided.
  408. /// </summary>
  409. /// <param name="adUnitIdentifier">The ad unit identifier of the MREC for which to update the position. Must not be null.</param>
  410. /// <param name="mrecPosition">A new position for the MREC. Must not be null.</param>
  411. public static void UpdateMRecPosition(string adUnitIdentifier, AdViewPosition mrecPosition)
  412. {
  413. ValidateAdUnitIdentifier(adUnitIdentifier, "update MREC position");
  414. MaxUnityPluginClass.CallStatic("updateMRecPosition", adUnitIdentifier, mrecPosition.ToSnakeCaseString());
  415. }
  416. /// <summary>
  417. /// Updates the position of the MREC to the new coordinates provided.
  418. /// </summary>
  419. /// <param name="adUnitIdentifier">The ad unit identifier of the MREC for which to update the position. Must not be null.</param>
  420. /// <param name="x">The X coordinate (horizontal position) of the MREC relative to the top left corner of the screen.</param>
  421. /// <param name="y">The Y coordinate (vertical position) of the MREC relative to the top left corner of the screen.</param>
  422. /// <seealso cref="GetMRecLayout">
  423. /// The MREC is placed within the safe area of the screen. You can use this to get the absolute position Rect of the MREC on screen.
  424. /// </seealso>
  425. public static void UpdateMRecPosition(string adUnitIdentifier, float x, float y)
  426. {
  427. ValidateAdUnitIdentifier(adUnitIdentifier, "update MREC position");
  428. MaxUnityPluginClass.CallStatic("updateMRecPosition", adUnitIdentifier, x, y);
  429. }
  430. /// <summary>
  431. /// Show MREC at a position determined by the 'CreateMRec' call.
  432. /// </summary>
  433. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to show. Must not be null.</param>
  434. public static void ShowMRec(string adUnitIdentifier)
  435. {
  436. ValidateAdUnitIdentifier(adUnitIdentifier, "show MREC");
  437. MaxUnityPluginClass.CallStatic("showMRec", adUnitIdentifier);
  438. }
  439. /// <summary>
  440. /// Remove MREC from the ad view and destroy it.
  441. /// </summary>
  442. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to destroy. Must not be null.</param>
  443. public static void DestroyMRec(string adUnitIdentifier)
  444. {
  445. ValidateAdUnitIdentifier(adUnitIdentifier, "destroy MREC");
  446. MaxUnityPluginClass.CallStatic("destroyMRec", adUnitIdentifier);
  447. }
  448. /// <summary>
  449. /// Hide MREC.
  450. /// </summary>
  451. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to hide. Must not be null.</param>
  452. public static void HideMRec(string adUnitIdentifier)
  453. {
  454. ValidateAdUnitIdentifier(adUnitIdentifier, "hide MREC");
  455. MaxUnityPluginClass.CallStatic("hideMRec", adUnitIdentifier);
  456. }
  457. /// <summary>
  458. /// Set an extra parameter for the MREC ad.
  459. /// </summary>
  460. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to set the extra parameter for. Must not be null.</param>
  461. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  462. /// <param name="value">The value for the extra parameter.</param>
  463. public static void SetMRecExtraParameter(string adUnitIdentifier, string key, string value)
  464. {
  465. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC extra parameter");
  466. MaxUnityPluginClass.CallStatic("setMRecExtraParameter", adUnitIdentifier, key, value);
  467. }
  468. /// <summary>
  469. /// Set a local extra parameter for the MREC ad.
  470. /// </summary>
  471. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to set the local extra parameter for. Must not be null.</param>
  472. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  473. /// <param name="value">The value for the extra parameter. Accepts the following types: <see cref="AndroidJavaObject"/>, <c>null</c>, <c>IList</c>, <c>IDictionary</c>, <c>string</c>, primitive types</param>
  474. public static void SetMRecLocalExtraParameter(string adUnitIdentifier, string key, object value)
  475. {
  476. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC local extra parameter");
  477. if (value == null || value is AndroidJavaObject)
  478. {
  479. MaxUnityPluginClass.CallStatic("setMRecLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  480. }
  481. else
  482. {
  483. MaxUnityPluginClass.CallStatic("setMRecLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  484. }
  485. }
  486. /// <summary>
  487. /// The custom data to tie the showing MREC ad to, for ILRD and rewarded postbacks via the <c>{CUSTOM_DATA}</c> macro. Maximum size is 8KB.
  488. /// </summary>
  489. /// <param name="adUnitIdentifier">MREC Ad unit identifier of the banner to set the custom data for. Must not be null.</param>
  490. /// <param name="customData">The custom data to be set.</param>
  491. public static void SetMRecCustomData(string adUnitIdentifier, string customData)
  492. {
  493. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC custom data");
  494. MaxUnityPluginClass.CallStatic("setMRecCustomData", adUnitIdentifier, customData);
  495. }
  496. /// <summary>
  497. /// The MREC position on the screen. When setting the banner position via <see cref="CreateMRec(string, float, float)"/> or <see cref="UpdateMRecPosition(string, float, float)"/>,
  498. /// the banner is placed within the safe area of the screen. This returns the absolute position of the MREC on screen.
  499. /// </summary>
  500. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC for which to get the position on screen. Must not be null.</param>
  501. /// <returns>A <see cref="Rect"/> representing the banner position on screen.</returns>
  502. public static Rect GetMRecLayout(string adUnitIdentifier)
  503. {
  504. ValidateAdUnitIdentifier(adUnitIdentifier, "get MREC layout");
  505. var positionRect = MaxUnityPluginClass.CallStatic<string>("getMRecLayout", adUnitIdentifier);
  506. return GetRectFromString(positionRect);
  507. }
  508. #endregion
  509. #region Interstitials
  510. /// <summary>
  511. /// Start loading an interstitial.
  512. /// </summary>
  513. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  514. public static void LoadInterstitial(string adUnitIdentifier)
  515. {
  516. ValidateAdUnitIdentifier(adUnitIdentifier, "load interstitial");
  517. MaxUnityPluginClass.CallStatic("loadInterstitial", adUnitIdentifier);
  518. }
  519. /// <summary>
  520. /// Check if interstitial ad is loaded and ready to be displayed.
  521. /// </summary>
  522. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  523. /// <returns>True if the ad is ready to be displayed</returns>
  524. public static bool IsInterstitialReady(string adUnitIdentifier)
  525. {
  526. ValidateAdUnitIdentifier(adUnitIdentifier, "check interstitial loaded");
  527. return MaxUnityPluginClass.CallStatic<bool>("isInterstitialReady", adUnitIdentifier);
  528. }
  529. /// <summary>
  530. /// Present loaded interstitial for a given placement to tie ad events to. Note: if the interstitial is not ready to be displayed nothing will happen.
  531. /// </summary>
  532. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  533. /// <param name="placement">The placement to tie the showing ad's events to</param>
  534. /// <param name="customData">The custom data to tie the showing ad's events to. Maximum size is 8KB.</param>
  535. public static void ShowInterstitial(string adUnitIdentifier, string placement = null, string customData = null)
  536. {
  537. ValidateAdUnitIdentifier(adUnitIdentifier, "show interstitial");
  538. if (IsInterstitialReady(adUnitIdentifier))
  539. {
  540. MaxUnityPluginClass.CallStatic("showInterstitial", adUnitIdentifier, placement, customData);
  541. }
  542. else
  543. {
  544. MaxSdkLogger.UserWarning("Not showing MAX Ads interstitial: ad not ready");
  545. }
  546. }
  547. /// <summary>
  548. /// Set an extra parameter for the ad.
  549. /// </summary>
  550. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to set the extra parameter for. Must not be null.</param>
  551. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  552. /// <param name="value">The value for the extra parameter.</param>
  553. public static void SetInterstitialExtraParameter(string adUnitIdentifier, string key, string value)
  554. {
  555. ValidateAdUnitIdentifier(adUnitIdentifier, "set interstitial extra parameter");
  556. MaxUnityPluginClass.CallStatic("setInterstitialExtraParameter", adUnitIdentifier, key, value);
  557. }
  558. /// <summary>
  559. /// Set a local extra parameter for the ad.
  560. /// </summary>
  561. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to set the local extra parameter for. Must not be null.</param>
  562. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  563. /// <param name="value">The value for the extra parameter. Accepts the following types: <see cref="AndroidJavaObject"/>, <c>null</c>, <c>IList</c>, <c>IDictionary</c>, <c>string</c>, primitive types</param>
  564. public static void SetInterstitialLocalExtraParameter(string adUnitIdentifier, string key, object value)
  565. {
  566. ValidateAdUnitIdentifier(adUnitIdentifier, "set interstitial local extra parameter");
  567. if (value == null || value is AndroidJavaObject)
  568. {
  569. MaxUnityPluginClass.CallStatic("setInterstitialLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  570. }
  571. else
  572. {
  573. MaxUnityPluginClass.CallStatic("setInterstitialLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  574. }
  575. }
  576. #endregion
  577. #region App Open
  578. /// <summary>
  579. /// Start loading an app open ad.
  580. /// </summary>
  581. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to load. Must not be null.</param>
  582. public static void LoadAppOpenAd(string adUnitIdentifier)
  583. {
  584. ValidateAdUnitIdentifier(adUnitIdentifier, "load app open ad");
  585. MaxUnityPluginClass.CallStatic("loadAppOpenAd", adUnitIdentifier);
  586. }
  587. /// <summary>
  588. /// Check if app open ad ad is loaded and ready to be displayed.
  589. /// </summary>
  590. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to load. Must not be null.</param>
  591. /// <returns>True if the ad is ready to be displayed</returns>
  592. public static bool IsAppOpenAdReady(string adUnitIdentifier)
  593. {
  594. ValidateAdUnitIdentifier(adUnitIdentifier, "check app open ad loaded");
  595. return MaxUnityPluginClass.CallStatic<bool>("isAppOpenAdReady", adUnitIdentifier);
  596. }
  597. /// <summary>
  598. /// Present loaded app open ad for a given placement to tie ad events to. Note: if the app open ad is not ready to be displayed nothing will happen.
  599. /// </summary>
  600. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to load. Must not be null.</param>
  601. /// <param name="placement">The placement to tie the showing ad's events to</param>
  602. /// <param name="customData">The custom data to tie the showing ad's events to. Maximum size is 8KB.</param>
  603. public static void ShowAppOpenAd(string adUnitIdentifier, string placement = null, string customData = null)
  604. {
  605. ValidateAdUnitIdentifier(adUnitIdentifier, "show app open ad");
  606. if (IsAppOpenAdReady(adUnitIdentifier))
  607. {
  608. MaxUnityPluginClass.CallStatic("showAppOpenAd", adUnitIdentifier, placement, customData);
  609. }
  610. else
  611. {
  612. MaxSdkLogger.UserWarning("Not showing MAX Ads app open ad: ad not ready");
  613. }
  614. }
  615. /// <summary>
  616. /// Set an extra parameter for the ad.
  617. /// </summary>
  618. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to set the extra parameter for. Must not be null.</param>
  619. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  620. /// <param name="value">The value for the extra parameter.</param>
  621. public static void SetAppOpenAdExtraParameter(string adUnitIdentifier, string key, string value)
  622. {
  623. ValidateAdUnitIdentifier(adUnitIdentifier, "set app open ad extra parameter");
  624. MaxUnityPluginClass.CallStatic("setAppOpenAdExtraParameter", adUnitIdentifier, key, value);
  625. }
  626. /// <summary>
  627. /// Set a local extra parameter for the ad.
  628. /// </summary>
  629. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to set the local extra parameter for. Must not be null.</param>
  630. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  631. /// <param name="value">The value for the extra parameter. Accepts the following types: <see cref="AndroidJavaObject"/>, <c>null</c>, <c>IList</c>, <c>IDictionary</c>, <c>string</c>, primitive types</param>
  632. public static void SetAppOpenAdLocalExtraParameter(string adUnitIdentifier, string key, object value)
  633. {
  634. ValidateAdUnitIdentifier(adUnitIdentifier, "set app open ad local extra parameter");
  635. if (value == null || value is AndroidJavaObject)
  636. {
  637. MaxUnityPluginClass.CallStatic("setAppOpenAdLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  638. }
  639. else
  640. {
  641. MaxUnityPluginClass.CallStatic("setAppOpenAdLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  642. }
  643. }
  644. #endregion
  645. #region Rewarded
  646. /// <summary>
  647. /// Start loading an rewarded ad.
  648. /// </summary>
  649. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded ad to load. Must not be null.</param>
  650. public static void LoadRewardedAd(string adUnitIdentifier)
  651. {
  652. ValidateAdUnitIdentifier(adUnitIdentifier, "load rewarded ad");
  653. MaxUnityPluginClass.CallStatic("loadRewardedAd", adUnitIdentifier);
  654. }
  655. /// <summary>
  656. /// Check if rewarded ad ad is loaded and ready to be displayed.
  657. /// </summary>
  658. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded ad to load. Must not be null.</param>
  659. /// <returns>True if the ad is ready to be displayed</returns>
  660. public static bool IsRewardedAdReady(string adUnitIdentifier)
  661. {
  662. ValidateAdUnitIdentifier(adUnitIdentifier, "check rewarded ad loaded");
  663. return MaxUnityPluginClass.CallStatic<bool>("isRewardedAdReady", adUnitIdentifier);
  664. }
  665. /// <summary> ready to be
  666. /// Present loaded rewarded ad for a given placement to tie ad events to. Note: if the rewarded ad is not ready to be displayed nothing will happen.
  667. /// </summary>
  668. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  669. /// <param name="placement">The placement to tie the showing ad's events to</param>
  670. /// <param name="customData">The custom data to tie the showing ad's events to. Maximum size is 8KB.</param>
  671. public static void ShowRewardedAd(string adUnitIdentifier, string placement = null, string customData = null)
  672. {
  673. ValidateAdUnitIdentifier(adUnitIdentifier, "show rewarded ad");
  674. if (IsRewardedAdReady(adUnitIdentifier))
  675. {
  676. MaxUnityPluginClass.CallStatic("showRewardedAd", adUnitIdentifier, placement, customData);
  677. }
  678. else
  679. {
  680. MaxSdkLogger.UserWarning("Not showing MAX Ads rewarded ad: ad not ready");
  681. }
  682. }
  683. /// <summary>
  684. /// Set an extra parameter for the ad.
  685. /// </summary>
  686. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded to set the extra parameter for. Must not be null.</param>
  687. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  688. /// <param name="value">The value for the extra parameter.</param>
  689. public static void SetRewardedAdExtraParameter(string adUnitIdentifier, string key, string value)
  690. {
  691. ValidateAdUnitIdentifier(adUnitIdentifier, "set rewarded ad extra parameter");
  692. MaxUnityPluginClass.CallStatic("setRewardedAdExtraParameter", adUnitIdentifier, key, value);
  693. }
  694. /// <summary>
  695. /// Set a local extra parameter for the ad.
  696. /// </summary>
  697. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded to set the local extra parameter for. Must not be null.</param>
  698. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  699. /// <param name="value">The value for the extra parameter. Accepts the following types: <see cref="AndroidJavaObject"/>, <c>null</c>, <c>IList</c>, <c>IDictionary</c>, <c>string</c>, primitive types</param>
  700. public static void SetRewardedAdLocalExtraParameter(string adUnitIdentifier, string key, object value)
  701. {
  702. ValidateAdUnitIdentifier(adUnitIdentifier, "set rewarded ad local extra parameter");
  703. if (value == null || value is AndroidJavaObject)
  704. {
  705. MaxUnityPluginClass.CallStatic("setRewardedAdLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  706. }
  707. else
  708. {
  709. MaxUnityPluginClass.CallStatic("setRewardedAdLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  710. }
  711. }
  712. #endregion
  713. #region Event Tracking
  714. /// <summary>
  715. /// Track an event using AppLovin.
  716. /// </summary>
  717. /// <param name="name">An event from the list of pre-defined events may be found in MaxEvents.cs as part of the AppLovin SDK framework. Must not be null.</param>
  718. /// <param name="parameters">A dictionary containing key-value pairs further describing this event.</param>
  719. public static void TrackEvent(string name, IDictionary<string, string> parameters = null)
  720. {
  721. MaxUnityPluginClass.CallStatic("trackEvent", name, Json.Serialize(parameters));
  722. }
  723. #endregion
  724. #region Settings
  725. /// <summary>
  726. /// Set whether to begin video ads in a muted state or not.
  727. ///
  728. /// Please call this method after the SDK has initialized.
  729. /// </summary>
  730. /// <param name="muted"><c>true</c> if video ads should being in muted state.</param>
  731. public static void SetMuted(bool muted)
  732. {
  733. MaxUnityPluginClass.CallStatic("setMuted", muted);
  734. }
  735. /// <summary>
  736. /// Whether video ads begin in a muted state or not. Defaults to <c>false</c>.
  737. ///
  738. /// Note: Returns <c>false</c> if the SDK is not initialized.
  739. /// </summary>
  740. /// <returns><c>true</c> if video ads begin in muted state.</returns>
  741. public static bool IsMuted()
  742. {
  743. return MaxUnityPluginClass.CallStatic<bool>("isMuted");
  744. }
  745. /// <summary>
  746. /// Toggle verbose logging of AppLovin SDK. If enabled AppLovin messages will appear in standard application log accessible via logcat. All log messages will have "AppLovinSdk" tag.
  747. /// </summary>
  748. /// <param name="enabled"><c>true</c> if verbose logging should be enabled.</param>
  749. public static void SetVerboseLogging(bool enabled)
  750. {
  751. MaxUnityPluginClass.CallStatic("setVerboseLogging", enabled);
  752. }
  753. /// <summary>
  754. /// Whether or not verbose logging is enabled.
  755. /// </summary>
  756. /// <returns><c>true</c> if verbose logging is enabled.</returns>
  757. public static bool IsVerboseLoggingEnabled()
  758. {
  759. return MaxUnityPluginClass.CallStatic<bool>("isVerboseLoggingEnabled");
  760. }
  761. /// <summary>
  762. /// Whether the creative debugger will be displayed on fullscreen ads after flipping the device screen down twice. Defaults to true.
  763. /// </summary>
  764. /// <param name="enabled"><c>true</c> if the creative debugger should be enabled.</param>
  765. public static void SetCreativeDebuggerEnabled(bool enabled)
  766. {
  767. MaxUnityPluginClass.CallStatic("setCreativeDebuggerEnabled", enabled);
  768. }
  769. /// <summary>
  770. /// Enable devices to receive test ads, by passing in the advertising identifier (IDFA/GAID) of each test device.
  771. /// Refer to AppLovin logs for the IDFA/GAID of your current device.
  772. /// </summary>
  773. /// <param name="advertisingIdentifiers">String list of advertising identifiers from devices to receive test ads.</param>
  774. public static void SetTestDeviceAdvertisingIdentifiers(string[] advertisingIdentifiers)
  775. {
  776. if (IsInitialized())
  777. {
  778. MaxSdkLogger.UserError("Test Device Advertising Identifiers must be set before SDK initialization.");
  779. return;
  780. }
  781. // Wrap the string array in an object array, so the compiler does not split into multiple strings.
  782. object[] arguments = {advertisingIdentifiers};
  783. MaxUnityPluginClass.CallStatic("setTestDeviceAdvertisingIds", arguments);
  784. }
  785. /// <summary>
  786. /// Whether or not the native AppLovin SDKs listen to exceptions. Defaults to <c>true</c>.
  787. /// </summary>
  788. /// <param name="enabled"><c>true</c> if the native AppLovin SDKs should not listen to exceptions.</param>
  789. public static void SetExceptionHandlerEnabled(bool enabled)
  790. {
  791. MaxUnityPluginClass.CallStatic("setExceptionHandlerEnabled", enabled);
  792. }
  793. /// <summary>
  794. /// Set an extra parameter to pass to the AppLovin server.
  795. /// </summary>
  796. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  797. /// <param name="value">The value for the extra parameter. May be null.</param>
  798. public static void SetExtraParameter(string key, string value)
  799. {
  800. HandleExtraParameter(key, value);
  801. MaxUnityPluginClass.CallStatic("setExtraParameter", key, value);
  802. }
  803. /// <summary>
  804. /// Get the native insets in pixels for the safe area.
  805. /// These insets are used to position ads within the safe area of the screen.
  806. /// </summary>
  807. public static SafeAreaInsets GetSafeAreaInsets()
  808. {
  809. // Use an int array instead of json serialization for performance
  810. var insets = MaxUnityPluginClass.CallStatic<int[]>("getSafeAreaInsets");
  811. // Convert from points to pixels
  812. var screenDensity = MaxSdkUtils.GetScreenDensity();
  813. for (var i = 0; i < insets.Length; i++)
  814. {
  815. insets[i] *= (int) screenDensity;
  816. }
  817. return new SafeAreaInsets(insets);
  818. }
  819. #endregion
  820. #region Obsolete
  821. [Obsolete("This API has been deprecated and will be removed in a future release. Please use CreateBanner(string adUnitIdentifier, AdViewConfiguration configuration) instead.")]
  822. public static void CreateBanner(string adUnitIdentifier, BannerPosition bannerPosition)
  823. {
  824. // AdViewPosition and BannerPosition share identical enum values, so casting is safe
  825. CreateBanner(adUnitIdentifier, new AdViewConfiguration((AdViewPosition) bannerPosition));
  826. }
  827. [Obsolete("This API has been deprecated and will be removed in a future release. Please use CreateBanner(string adUnitIdentifier, AdViewConfiguration configuration) instead.")]
  828. public static void CreateBanner(string adUnitIdentifier, float x, float y)
  829. {
  830. CreateBanner(adUnitIdentifier, new AdViewConfiguration(x, y));
  831. }
  832. [Obsolete("This API has been deprecated and will be removed in a future release. Please use UpdateBannerPosition(string adUnitIdentifier, AdViewPosition bannerPosition) instead.")]
  833. public static void UpdateBannerPosition(string adUnitIdentifier, BannerPosition bannerPosition)
  834. {
  835. // AdViewPosition and BannerPosition share identical enum values, so casting is safe
  836. UpdateBannerPosition(adUnitIdentifier, (AdViewPosition) bannerPosition);
  837. }
  838. [Obsolete("This API has been deprecated and will be removed in a future release. Please use CreateMRec(string adUnitIdentifier, AdViewConfiguration configuration) instead.")]
  839. public static void CreateMRec(string adUnitIdentifier, AdViewPosition mrecPosition)
  840. {
  841. CreateMRec(adUnitIdentifier, new AdViewConfiguration(mrecPosition));
  842. }
  843. [Obsolete("This API has been deprecated and will be removed in a future release. Please use CreateMRec(string adUnitIdentifier, AdViewConfiguration configuration) instead.")]
  844. public static void CreateMRec(string adUnitIdentifier, float x, float y)
  845. {
  846. CreateMRec(adUnitIdentifier, new AdViewConfiguration(x, y));
  847. }
  848. [Obsolete("This API has been deprecated and will be removed in a future release. Please set your SDK key in the AppLovin Integration Manager.")]
  849. public static void SetSdkKey(string sdkKey)
  850. {
  851. MaxUnityPluginClass.CallStatic("setSdkKey", sdkKey);
  852. MaxSdkLogger.UserWarning("MaxSdk.SetSdkKey() has been deprecated and will be removed in a future release. Please set your SDK key in the AppLovin Integration Manager.");
  853. }
  854. #endregion
  855. internal class BackgroundCallbackProxy : AndroidJavaProxy
  856. {
  857. public BackgroundCallbackProxy() : base("com.applovin.mediation.unity.MaxUnityAdManager$BackgroundCallback") { }
  858. public void onEvent(string propsStr)
  859. {
  860. HandleBackgroundCallback(propsStr);
  861. }
  862. }
  863. }
  864. #endif