MaxSdkAndroid.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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="bannerPosition">Banner position. Must not be null.</param>
  175. public static void CreateBanner(string adUnitIdentifier, BannerPosition bannerPosition)
  176. {
  177. ValidateAdUnitIdentifier(adUnitIdentifier, "create banner");
  178. MaxUnityPluginClass.CallStatic("createBanner", adUnitIdentifier, bannerPosition.ToSnakeCaseString());
  179. }
  180. /// <summary>
  181. /// Create a new banner with a custom position.
  182. /// </summary>
  183. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to create. Must not be null.</param>
  184. /// <param name="x">The X coordinate (horizontal position) of the banner relative to the top left corner of the screen.</param>
  185. /// <param name="y">The Y coordinate (vertical position) of the banner relative to the top left corner of the screen.</param>
  186. /// <seealso cref="GetBannerLayout">
  187. /// 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.
  188. /// </seealso>
  189. public static void CreateBanner(string adUnitIdentifier, float x, float y)
  190. {
  191. ValidateAdUnitIdentifier(adUnitIdentifier, "create banner");
  192. MaxUnityPluginClass.CallStatic("createBanner", adUnitIdentifier, x, y);
  193. }
  194. /// <summary>
  195. /// Load a new banner ad.
  196. /// NOTE: The <see cref="CreateBanner()"/> method loads the first banner ad and initiates an automated banner refresh process.
  197. /// You only need to call this method if you pause banner refresh.
  198. /// </summary>
  199. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to load. Must not be null.</param>
  200. public static void LoadBanner(string adUnitIdentifier)
  201. {
  202. ValidateAdUnitIdentifier(adUnitIdentifier, "load banner");
  203. MaxUnityPluginClass.CallStatic("loadBanner", adUnitIdentifier);
  204. }
  205. /// <summary>
  206. /// Set the banner placement for an ad unit identifier to tie the future ad events to.
  207. /// </summary>
  208. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set the placement for. Must not be null.</param>
  209. /// <param name="placement">Placement to set</param>
  210. public static void SetBannerPlacement(string adUnitIdentifier, string placement)
  211. {
  212. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner placement");
  213. MaxUnityPluginClass.CallStatic("setBannerPlacement", adUnitIdentifier, placement);
  214. }
  215. /// <summary>
  216. /// Starts or resumes auto-refreshing of the banner for the given ad unit identifier.
  217. /// </summary>
  218. /// <param name="adUnitIdentifier">Ad unit identifier of the banner for which to start auto-refresh. Must not be null.</param>
  219. public static void StartBannerAutoRefresh(string adUnitIdentifier)
  220. {
  221. ValidateAdUnitIdentifier(adUnitIdentifier, "start banner auto-refresh");
  222. MaxUnityPluginClass.CallStatic("startBannerAutoRefresh", adUnitIdentifier);
  223. }
  224. /// <summary>
  225. /// Pauses auto-refreshing of the banner for the given ad unit identifier.
  226. /// </summary>
  227. /// <param name="adUnitIdentifier">Ad unit identifier of the banner for which to stop auto-refresh. Must not be null.</param>
  228. public static void StopBannerAutoRefresh(string adUnitIdentifier)
  229. {
  230. ValidateAdUnitIdentifier(adUnitIdentifier, "stop banner auto-refresh");
  231. MaxUnityPluginClass.CallStatic("stopBannerAutoRefresh", adUnitIdentifier);
  232. }
  233. /// <summary>
  234. /// Updates the position of the banner to the new position provided.
  235. /// </summary>
  236. /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to update the position. Must not be null.</param>
  237. /// <param name="bannerPosition">A new position for the banner. Must not be null.</param>
  238. public static void UpdateBannerPosition(string adUnitIdentifier, BannerPosition bannerPosition)
  239. {
  240. ValidateAdUnitIdentifier(adUnitIdentifier, "update banner position");
  241. MaxUnityPluginClass.CallStatic("updateBannerPosition", adUnitIdentifier, bannerPosition.ToSnakeCaseString());
  242. }
  243. /// <summary>
  244. /// Updates the position of the banner to the new coordinates provided.
  245. /// </summary>
  246. /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to update the position. Must not be null.</param>
  247. /// <param name="x">The X coordinate (horizontal position) of the banner relative to the top left corner of the screen.</param>
  248. /// <param name="y">The Y coordinate (vertical position) of the banner relative to the top left corner of the screen.</param>
  249. /// <seealso cref="GetBannerLayout">
  250. /// 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.
  251. /// </seealso>
  252. public static void UpdateBannerPosition(string adUnitIdentifier, float x, float y)
  253. {
  254. ValidateAdUnitIdentifier(adUnitIdentifier, "update banner position");
  255. MaxUnityPluginClass.CallStatic("updateBannerPosition", adUnitIdentifier, x, y);
  256. }
  257. /// <summary>
  258. /// Overrides the width of the banner in dp.
  259. /// </summary>
  260. /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to override the width for. Must not be null.</param>
  261. /// <param name="width">The desired width of the banner in dp</param>
  262. public static void SetBannerWidth(string adUnitIdentifier, float width)
  263. {
  264. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner width");
  265. MaxUnityPluginClass.CallStatic("setBannerWidth", adUnitIdentifier, width);
  266. }
  267. /// <summary>
  268. /// Show banner at a position determined by the 'CreateBanner' call.
  269. /// </summary>
  270. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to show. Must not be null.</param>
  271. public static void ShowBanner(string adUnitIdentifier)
  272. {
  273. ValidateAdUnitIdentifier(adUnitIdentifier, "show banner");
  274. MaxUnityPluginClass.CallStatic("showBanner", adUnitIdentifier);
  275. }
  276. /// <summary>
  277. /// Remove banner from the ad view and destroy it.
  278. /// </summary>
  279. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to destroy. Must not be null.</param>
  280. public static void DestroyBanner(string adUnitIdentifier)
  281. {
  282. ValidateAdUnitIdentifier(adUnitIdentifier, "destroy banner");
  283. MaxUnityPluginClass.CallStatic("destroyBanner", adUnitIdentifier);
  284. }
  285. /// <summary>
  286. /// Hide banner.
  287. /// </summary>
  288. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to hide. Must not be null.</param>
  289. public static void HideBanner(string adUnitIdentifier)
  290. {
  291. ValidateAdUnitIdentifier(adUnitIdentifier, "hide banner");
  292. MaxUnityPluginClass.CallStatic("hideBanner", adUnitIdentifier);
  293. }
  294. /// <summary>
  295. /// Set non-transparent background color for banners to be fully functional.
  296. /// </summary>
  297. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set background color for. Must not be null.</param>
  298. /// <param name="color">A background color to set for the ad. Must not be null.</param>
  299. public static void SetBannerBackgroundColor(string adUnitIdentifier, Color color)
  300. {
  301. ValidateAdUnitIdentifier(adUnitIdentifier, "set background color");
  302. MaxUnityPluginClass.CallStatic("setBannerBackgroundColor", adUnitIdentifier, MaxSdkUtils.ParseColor(color));
  303. }
  304. /// <summary>
  305. /// Set an extra parameter for the banner ad.
  306. /// </summary>
  307. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set the extra parameter for. Must not be null.</param>
  308. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  309. /// <param name="value">The value for the extra parameter.</param>
  310. public static void SetBannerExtraParameter(string adUnitIdentifier, string key, string value)
  311. {
  312. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner extra parameter");
  313. MaxUnityPluginClass.CallStatic("setBannerExtraParameter", adUnitIdentifier, key, value);
  314. }
  315. /// <summary>
  316. /// Set a local extra parameter for the banner ad.
  317. /// </summary>
  318. /// <param name="adUnitIdentifier">Ad unit identifier of the banner to set the local extra parameter for. Must not be null.</param>
  319. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  320. /// <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>
  321. public static void SetBannerLocalExtraParameter(string adUnitIdentifier, string key, object value)
  322. {
  323. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner local extra parameter");
  324. if (value == null || value is AndroidJavaObject)
  325. {
  326. MaxUnityPluginClass.CallStatic("setBannerLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  327. }
  328. else
  329. {
  330. MaxUnityPluginClass.CallStatic("setBannerLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  331. }
  332. }
  333. /// <summary>
  334. /// 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.
  335. /// </summary>
  336. /// <param name="adUnitIdentifier">Banner ad unit identifier of the banner to set the custom data for. Must not be null.</param>
  337. /// <param name="customData">The custom data to be set.</param>
  338. public static void SetBannerCustomData(string adUnitIdentifier, string customData)
  339. {
  340. ValidateAdUnitIdentifier(adUnitIdentifier, "set banner custom data");
  341. MaxUnityPluginClass.CallStatic("setBannerCustomData", adUnitIdentifier, customData);
  342. }
  343. /// <summary>
  344. /// 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)"/>,
  345. /// the banner is placed within the safe area of the screen. This returns the absolute position of the banner on screen.
  346. /// </summary>
  347. /// <param name="adUnitIdentifier">Ad unit identifier of the banner for which to get the position on screen. Must not be null.</param>
  348. /// <returns>A <see cref="Rect"/> representing the banner position on screen.</returns>
  349. public static Rect GetBannerLayout(string adUnitIdentifier)
  350. {
  351. ValidateAdUnitIdentifier(adUnitIdentifier, "get banner layout");
  352. var positionRect = MaxUnityPluginClass.CallStatic<string>("getBannerLayout", adUnitIdentifier);
  353. return GetRectFromString(positionRect);
  354. }
  355. #endregion
  356. #region MRECs
  357. /// <summary>
  358. /// Create a new MREC.
  359. /// </summary>
  360. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to create. Must not be null.</param>
  361. /// <param name="mrecPosition">MREC position. Must not be null.</param>
  362. public static void CreateMRec(string adUnitIdentifier, AdViewPosition mrecPosition)
  363. {
  364. ValidateAdUnitIdentifier(adUnitIdentifier, "create MREC");
  365. MaxUnityPluginClass.CallStatic("createMRec", adUnitIdentifier, mrecPosition.ToSnakeCaseString());
  366. }
  367. /// <summary>
  368. /// Create a new MREC with a custom position.
  369. /// </summary>
  370. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to create. Must not be null.</param>
  371. /// <param name="x">The X coordinate (horizontal position) of the MREC relative to the top left corner of the screen.</param>
  372. /// <param name="y">The Y coordinate (vertical position) of the MREC relative to the top left corner of the screen.</param>
  373. /// <seealso cref="GetMRecLayout">
  374. /// 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.
  375. /// </seealso>
  376. public static void CreateMRec(string adUnitIdentifier, float x, float y)
  377. {
  378. ValidateAdUnitIdentifier(adUnitIdentifier, "create MREC");
  379. MaxUnityPluginClass.CallStatic("createMRec", adUnitIdentifier, x, y);
  380. }
  381. /// <summary>
  382. /// Load a new MREC ad.
  383. /// NOTE: The <see cref="CreateMRec()"/> method loads the first MREC ad and initiates an automated MREC refresh process.
  384. /// You only need to call this method if you pause MREC refresh.
  385. /// </summary>
  386. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to load. Must not be null.</param>
  387. public static void LoadMRec(string adUnitIdentifier)
  388. {
  389. ValidateAdUnitIdentifier(adUnitIdentifier, "load MREC");
  390. MaxUnityPluginClass.CallStatic("loadMRec", adUnitIdentifier);
  391. }
  392. /// <summary>
  393. /// Set the MREC placement for an ad unit identifier to tie the future ad events to.
  394. /// </summary>
  395. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to set the placement for. Must not be null.</param>
  396. /// <param name="placement">Placement to set</param>
  397. public static void SetMRecPlacement(string adUnitIdentifier, string placement)
  398. {
  399. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC placement");
  400. MaxUnityPluginClass.CallStatic("setMRecPlacement", adUnitIdentifier, placement);
  401. }
  402. /// <summary>
  403. /// Starts or resumes auto-refreshing of the MREC for the given ad unit identifier.
  404. /// </summary>
  405. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC for which to start auto-refresh. Must not be null.</param>
  406. public static void StartMRecAutoRefresh(string adUnitIdentifier)
  407. {
  408. ValidateAdUnitIdentifier(adUnitIdentifier, "start MREC auto-refresh");
  409. MaxUnityPluginClass.CallStatic("startMRecAutoRefresh", adUnitIdentifier);
  410. }
  411. /// <summary>
  412. /// Pauses auto-refreshing of the MREC for the given ad unit identifier.
  413. /// </summary>
  414. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC for which to stop auto-refresh. Must not be null.</param>
  415. public static void StopMRecAutoRefresh(string adUnitIdentifier)
  416. {
  417. ValidateAdUnitIdentifier(adUnitIdentifier, "stop MREC auto-refresh");
  418. MaxUnityPluginClass.CallStatic("stopMRecAutoRefresh", adUnitIdentifier);
  419. }
  420. /// <summary>
  421. /// Updates the position of the MREC to the new position provided.
  422. /// </summary>
  423. /// <param name="adUnitIdentifier">The ad unit identifier of the MREC for which to update the position. Must not be null.</param>
  424. /// <param name="mrecPosition">A new position for the MREC. Must not be null.</param>
  425. public static void UpdateMRecPosition(string adUnitIdentifier, AdViewPosition mrecPosition)
  426. {
  427. ValidateAdUnitIdentifier(adUnitIdentifier, "update MREC position");
  428. MaxUnityPluginClass.CallStatic("updateMRecPosition", adUnitIdentifier, mrecPosition.ToSnakeCaseString());
  429. }
  430. /// <summary>
  431. /// Updates the position of the MREC to the new coordinates provided.
  432. /// </summary>
  433. /// <param name="adUnitIdentifier">The ad unit identifier of the MREC for which to update the position. Must not be null.</param>
  434. /// <param name="x">The X coordinate (horizontal position) of the MREC relative to the top left corner of the screen.</param>
  435. /// <param name="y">The Y coordinate (vertical position) of the MREC relative to the top left corner of the screen.</param>
  436. /// <seealso cref="GetMRecLayout">
  437. /// 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.
  438. /// </seealso>
  439. public static void UpdateMRecPosition(string adUnitIdentifier, float x, float y)
  440. {
  441. ValidateAdUnitIdentifier(adUnitIdentifier, "update MREC position");
  442. MaxUnityPluginClass.CallStatic("updateMRecPosition", adUnitIdentifier, x, y);
  443. }
  444. /// <summary>
  445. /// Show MREC at a position determined by the 'CreateMRec' call.
  446. /// </summary>
  447. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to show. Must not be null.</param>
  448. public static void ShowMRec(string adUnitIdentifier)
  449. {
  450. ValidateAdUnitIdentifier(adUnitIdentifier, "show MREC");
  451. MaxUnityPluginClass.CallStatic("showMRec", adUnitIdentifier);
  452. }
  453. /// <summary>
  454. /// Remove MREC from the ad view and destroy it.
  455. /// </summary>
  456. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to destroy. Must not be null.</param>
  457. public static void DestroyMRec(string adUnitIdentifier)
  458. {
  459. ValidateAdUnitIdentifier(adUnitIdentifier, "destroy MREC");
  460. MaxUnityPluginClass.CallStatic("destroyMRec", adUnitIdentifier);
  461. }
  462. /// <summary>
  463. /// Hide MREC.
  464. /// </summary>
  465. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to hide. Must not be null.</param>
  466. public static void HideMRec(string adUnitIdentifier)
  467. {
  468. ValidateAdUnitIdentifier(adUnitIdentifier, "hide MREC");
  469. MaxUnityPluginClass.CallStatic("hideMRec", adUnitIdentifier);
  470. }
  471. /// <summary>
  472. /// Set an extra parameter for the MREC ad.
  473. /// </summary>
  474. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to set the extra parameter for. Must not be null.</param>
  475. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  476. /// <param name="value">The value for the extra parameter.</param>
  477. public static void SetMRecExtraParameter(string adUnitIdentifier, string key, string value)
  478. {
  479. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC extra parameter");
  480. MaxUnityPluginClass.CallStatic("setMRecExtraParameter", adUnitIdentifier, key, value);
  481. }
  482. /// <summary>
  483. /// Set a local extra parameter for the MREC ad.
  484. /// </summary>
  485. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC to set the local extra parameter for. Must not be null.</param>
  486. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  487. /// <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>
  488. public static void SetMRecLocalExtraParameter(string adUnitIdentifier, string key, object value)
  489. {
  490. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC local extra parameter");
  491. if (value == null || value is AndroidJavaObject)
  492. {
  493. MaxUnityPluginClass.CallStatic("setMRecLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  494. }
  495. else
  496. {
  497. MaxUnityPluginClass.CallStatic("setMRecLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  498. }
  499. }
  500. /// <summary>
  501. /// 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.
  502. /// </summary>
  503. /// <param name="adUnitIdentifier">MREC Ad unit identifier of the banner to set the custom data for. Must not be null.</param>
  504. /// <param name="customData">The custom data to be set.</param>
  505. public static void SetMRecCustomData(string adUnitIdentifier, string customData)
  506. {
  507. ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC custom data");
  508. MaxUnityPluginClass.CallStatic("setMRecCustomData", adUnitIdentifier, customData);
  509. }
  510. /// <summary>
  511. /// 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)"/>,
  512. /// the banner is placed within the safe area of the screen. This returns the absolute position of the MREC on screen.
  513. /// </summary>
  514. /// <param name="adUnitIdentifier">Ad unit identifier of the MREC for which to get the position on screen. Must not be null.</param>
  515. /// <returns>A <see cref="Rect"/> representing the banner position on screen.</returns>
  516. public static Rect GetMRecLayout(string adUnitIdentifier)
  517. {
  518. ValidateAdUnitIdentifier(adUnitIdentifier, "get MREC layout");
  519. var positionRect = MaxUnityPluginClass.CallStatic<string>("getMRecLayout", adUnitIdentifier);
  520. return GetRectFromString(positionRect);
  521. }
  522. #endregion
  523. #region Interstitials
  524. /// <summary>
  525. /// Start loading an interstitial.
  526. /// </summary>
  527. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  528. public static void LoadInterstitial(string adUnitIdentifier)
  529. {
  530. ValidateAdUnitIdentifier(adUnitIdentifier, "load interstitial");
  531. MaxUnityPluginClass.CallStatic("loadInterstitial", adUnitIdentifier);
  532. }
  533. /// <summary>
  534. /// Check if interstitial ad is loaded and ready to be displayed.
  535. /// </summary>
  536. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  537. /// <returns>True if the ad is ready to be displayed</returns>
  538. public static bool IsInterstitialReady(string adUnitIdentifier)
  539. {
  540. ValidateAdUnitIdentifier(adUnitIdentifier, "check interstitial loaded");
  541. return MaxUnityPluginClass.CallStatic<bool>("isInterstitialReady", adUnitIdentifier);
  542. }
  543. /// <summary>
  544. /// 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.
  545. /// </summary>
  546. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  547. /// <param name="placement">The placement to tie the showing ad's events to</param>
  548. /// <param name="customData">The custom data to tie the showing ad's events to. Maximum size is 8KB.</param>
  549. public static void ShowInterstitial(string adUnitIdentifier, string placement = null, string customData = null)
  550. {
  551. ValidateAdUnitIdentifier(adUnitIdentifier, "show interstitial");
  552. if (IsInterstitialReady(adUnitIdentifier))
  553. {
  554. MaxUnityPluginClass.CallStatic("showInterstitial", adUnitIdentifier, placement, customData);
  555. }
  556. else
  557. {
  558. MaxSdkLogger.UserWarning("Not showing MAX Ads interstitial: ad not ready");
  559. }
  560. }
  561. /// <summary>
  562. /// Set an extra parameter for the ad.
  563. /// </summary>
  564. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to set the extra parameter for. Must not be null.</param>
  565. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  566. /// <param name="value">The value for the extra parameter.</param>
  567. public static void SetInterstitialExtraParameter(string adUnitIdentifier, string key, string value)
  568. {
  569. ValidateAdUnitIdentifier(adUnitIdentifier, "set interstitial extra parameter");
  570. MaxUnityPluginClass.CallStatic("setInterstitialExtraParameter", adUnitIdentifier, key, value);
  571. }
  572. /// <summary>
  573. /// Set a local extra parameter for the ad.
  574. /// </summary>
  575. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to set the local extra parameter for. Must not be null.</param>
  576. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  577. /// <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>
  578. public static void SetInterstitialLocalExtraParameter(string adUnitIdentifier, string key, object value)
  579. {
  580. ValidateAdUnitIdentifier(adUnitIdentifier, "set interstitial local extra parameter");
  581. if (value == null || value is AndroidJavaObject)
  582. {
  583. MaxUnityPluginClass.CallStatic("setInterstitialLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  584. }
  585. else
  586. {
  587. MaxUnityPluginClass.CallStatic("setInterstitialLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  588. }
  589. }
  590. #endregion
  591. #region App Open
  592. /// <summary>
  593. /// Start loading an app open ad.
  594. /// </summary>
  595. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to load. Must not be null.</param>
  596. public static void LoadAppOpenAd(string adUnitIdentifier)
  597. {
  598. ValidateAdUnitIdentifier(adUnitIdentifier, "load app open ad");
  599. MaxUnityPluginClass.CallStatic("loadAppOpenAd", adUnitIdentifier);
  600. }
  601. /// <summary>
  602. /// Check if app open ad ad is loaded and ready to be displayed.
  603. /// </summary>
  604. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to load. Must not be null.</param>
  605. /// <returns>True if the ad is ready to be displayed</returns>
  606. public static bool IsAppOpenAdReady(string adUnitIdentifier)
  607. {
  608. ValidateAdUnitIdentifier(adUnitIdentifier, "check app open ad loaded");
  609. return MaxUnityPluginClass.CallStatic<bool>("isAppOpenAdReady", adUnitIdentifier);
  610. }
  611. /// <summary>
  612. /// 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.
  613. /// </summary>
  614. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to load. Must not be null.</param>
  615. /// <param name="placement">The placement to tie the showing ad's events to</param>
  616. /// <param name="customData">The custom data to tie the showing ad's events to. Maximum size is 8KB.</param>
  617. public static void ShowAppOpenAd(string adUnitIdentifier, string placement = null, string customData = null)
  618. {
  619. ValidateAdUnitIdentifier(adUnitIdentifier, "show app open ad");
  620. if (IsAppOpenAdReady(adUnitIdentifier))
  621. {
  622. MaxUnityPluginClass.CallStatic("showAppOpenAd", adUnitIdentifier, placement, customData);
  623. }
  624. else
  625. {
  626. MaxSdkLogger.UserWarning("Not showing MAX Ads app open ad: ad not ready");
  627. }
  628. }
  629. /// <summary>
  630. /// Set an extra parameter for the ad.
  631. /// </summary>
  632. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to set the extra parameter for. Must not be null.</param>
  633. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  634. /// <param name="value">The value for the extra parameter.</param>
  635. public static void SetAppOpenAdExtraParameter(string adUnitIdentifier, string key, string value)
  636. {
  637. ValidateAdUnitIdentifier(adUnitIdentifier, "set app open ad extra parameter");
  638. MaxUnityPluginClass.CallStatic("setAppOpenAdExtraParameter", adUnitIdentifier, key, value);
  639. }
  640. /// <summary>
  641. /// Set a local extra parameter for the ad.
  642. /// </summary>
  643. /// <param name="adUnitIdentifier">Ad unit identifier of the app open ad to set the local extra parameter for. Must not be null.</param>
  644. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  645. /// <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>
  646. public static void SetAppOpenAdLocalExtraParameter(string adUnitIdentifier, string key, object value)
  647. {
  648. ValidateAdUnitIdentifier(adUnitIdentifier, "set app open ad local extra parameter");
  649. if (value == null || value is AndroidJavaObject)
  650. {
  651. MaxUnityPluginClass.CallStatic("setAppOpenAdLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  652. }
  653. else
  654. {
  655. MaxUnityPluginClass.CallStatic("setAppOpenAdLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  656. }
  657. }
  658. #endregion
  659. #region Rewarded
  660. /// <summary>
  661. /// Start loading an rewarded ad.
  662. /// </summary>
  663. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded ad to load. Must not be null.</param>
  664. public static void LoadRewardedAd(string adUnitIdentifier)
  665. {
  666. ValidateAdUnitIdentifier(adUnitIdentifier, "load rewarded ad");
  667. MaxUnityPluginClass.CallStatic("loadRewardedAd", adUnitIdentifier);
  668. }
  669. /// <summary>
  670. /// Check if rewarded ad ad is loaded and ready to be displayed.
  671. /// </summary>
  672. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded ad to load. Must not be null.</param>
  673. /// <returns>True if the ad is ready to be displayed</returns>
  674. public static bool IsRewardedAdReady(string adUnitIdentifier)
  675. {
  676. ValidateAdUnitIdentifier(adUnitIdentifier, "check rewarded ad loaded");
  677. return MaxUnityPluginClass.CallStatic<bool>("isRewardedAdReady", adUnitIdentifier);
  678. }
  679. /// <summary> ready to be
  680. /// 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.
  681. /// </summary>
  682. /// <param name="adUnitIdentifier">Ad unit identifier of the interstitial to load. Must not be null.</param>
  683. /// <param name="placement">The placement to tie the showing ad's events to</param>
  684. /// <param name="customData">The custom data to tie the showing ad's events to. Maximum size is 8KB.</param>
  685. public static void ShowRewardedAd(string adUnitIdentifier, string placement = null, string customData = null)
  686. {
  687. ValidateAdUnitIdentifier(adUnitIdentifier, "show rewarded ad");
  688. if (IsRewardedAdReady(adUnitIdentifier))
  689. {
  690. MaxUnityPluginClass.CallStatic("showRewardedAd", adUnitIdentifier, placement, customData);
  691. }
  692. else
  693. {
  694. MaxSdkLogger.UserWarning("Not showing MAX Ads rewarded ad: ad not ready");
  695. }
  696. }
  697. /// <summary>
  698. /// Set an extra parameter for the ad.
  699. /// </summary>
  700. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded to set the extra parameter for. Must not be null.</param>
  701. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  702. /// <param name="value">The value for the extra parameter.</param>
  703. public static void SetRewardedAdExtraParameter(string adUnitIdentifier, string key, string value)
  704. {
  705. ValidateAdUnitIdentifier(adUnitIdentifier, "set rewarded ad extra parameter");
  706. MaxUnityPluginClass.CallStatic("setRewardedAdExtraParameter", adUnitIdentifier, key, value);
  707. }
  708. /// <summary>
  709. /// Set a local extra parameter for the ad.
  710. /// </summary>
  711. /// <param name="adUnitIdentifier">Ad unit identifier of the rewarded to set the local extra parameter for. Must not be null.</param>
  712. /// <param name="key">The key for the local extra parameter. Must not be null.</param>
  713. /// <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>
  714. public static void SetRewardedAdLocalExtraParameter(string adUnitIdentifier, string key, object value)
  715. {
  716. ValidateAdUnitIdentifier(adUnitIdentifier, "set rewarded ad local extra parameter");
  717. if (value == null || value is AndroidJavaObject)
  718. {
  719. MaxUnityPluginClass.CallStatic("setRewardedAdLocalExtraParameter", adUnitIdentifier, key, (AndroidJavaObject) value);
  720. }
  721. else
  722. {
  723. MaxUnityPluginClass.CallStatic("setRewardedAdLocalExtraParameterJson", adUnitIdentifier, key, SerializeLocalExtraParameterValue(value));
  724. }
  725. }
  726. #endregion
  727. #region Event Tracking
  728. /// <summary>
  729. /// Track an event using AppLovin.
  730. /// </summary>
  731. /// <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>
  732. /// <param name="parameters">A dictionary containing key-value pairs further describing this event.</param>
  733. public static void TrackEvent(string name, IDictionary<string, string> parameters = null)
  734. {
  735. MaxUnityPluginClass.CallStatic("trackEvent", name, Json.Serialize(parameters));
  736. }
  737. #endregion
  738. #region Settings
  739. /// <summary>
  740. /// Set whether to begin video ads in a muted state or not.
  741. ///
  742. /// Please call this method after the SDK has initialized.
  743. /// </summary>
  744. /// <param name="muted"><c>true</c> if video ads should being in muted state.</param>
  745. public static void SetMuted(bool muted)
  746. {
  747. MaxUnityPluginClass.CallStatic("setMuted", muted);
  748. }
  749. /// <summary>
  750. /// Whether video ads begin in a muted state or not. Defaults to <c>false</c>.
  751. ///
  752. /// Note: Returns <c>false</c> if the SDK is not initialized.
  753. /// </summary>
  754. /// <returns><c>true</c> if video ads begin in muted state.</returns>
  755. public static bool IsMuted()
  756. {
  757. return MaxUnityPluginClass.CallStatic<bool>("isMuted");
  758. }
  759. /// <summary>
  760. /// 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.
  761. /// </summary>
  762. /// <param name="enabled"><c>true</c> if verbose logging should be enabled.</param>
  763. public static void SetVerboseLogging(bool enabled)
  764. {
  765. MaxUnityPluginClass.CallStatic("setVerboseLogging", enabled);
  766. }
  767. /// <summary>
  768. /// Whether or not verbose logging is enabled.
  769. /// </summary>
  770. /// <returns><c>true</c> if verbose logging is enabled.</returns>
  771. public static bool IsVerboseLoggingEnabled()
  772. {
  773. return MaxUnityPluginClass.CallStatic<bool>("isVerboseLoggingEnabled");
  774. }
  775. /// <summary>
  776. /// Whether the creative debugger will be displayed on fullscreen ads after flipping the device screen down twice. Defaults to true.
  777. /// </summary>
  778. /// <param name="enabled"><c>true</c> if the creative debugger should be enabled.</param>
  779. public static void SetCreativeDebuggerEnabled(bool enabled)
  780. {
  781. MaxUnityPluginClass.CallStatic("setCreativeDebuggerEnabled", enabled);
  782. }
  783. /// <summary>
  784. /// Enable devices to receive test ads, by passing in the advertising identifier (IDFA/GAID) of each test device.
  785. /// Refer to AppLovin logs for the IDFA/GAID of your current device.
  786. /// </summary>
  787. /// <param name="advertisingIdentifiers">String list of advertising identifiers from devices to receive test ads.</param>
  788. public static void SetTestDeviceAdvertisingIdentifiers(string[] advertisingIdentifiers)
  789. {
  790. if (IsInitialized())
  791. {
  792. MaxSdkLogger.UserError("Test Device Advertising Identifiers must be set before SDK initialization.");
  793. return;
  794. }
  795. // Wrap the string array in an object array, so the compiler does not split into multiple strings.
  796. object[] arguments = {advertisingIdentifiers};
  797. MaxUnityPluginClass.CallStatic("setTestDeviceAdvertisingIds", arguments);
  798. }
  799. /// <summary>
  800. /// Whether or not the native AppLovin SDKs listen to exceptions. Defaults to <c>true</c>.
  801. /// </summary>
  802. /// <param name="enabled"><c>true</c> if the native AppLovin SDKs should not listen to exceptions.</param>
  803. public static void SetExceptionHandlerEnabled(bool enabled)
  804. {
  805. MaxUnityPluginClass.CallStatic("setExceptionHandlerEnabled", enabled);
  806. }
  807. /// <summary>
  808. /// Set an extra parameter to pass to the AppLovin server.
  809. /// </summary>
  810. /// <param name="key">The key for the extra parameter. Must not be null.</param>
  811. /// <param name="value">The value for the extra parameter. May be null.</param>
  812. public static void SetExtraParameter(string key, string value)
  813. {
  814. HandleExtraParameter(key, value);
  815. MaxUnityPluginClass.CallStatic("setExtraParameter", key, value);
  816. }
  817. /// <summary>
  818. /// Get the native insets in pixels for the safe area.
  819. /// These insets are used to position ads within the safe area of the screen.
  820. /// </summary>
  821. public static SafeAreaInsets GetSafeAreaInsets()
  822. {
  823. // Use an int array instead of json serialization for performance
  824. var insets = MaxUnityPluginClass.CallStatic<int[]>("getSafeAreaInsets");
  825. // Convert from points to pixels
  826. var screenDensity = MaxSdkUtils.GetScreenDensity();
  827. for (var i = 0; i < insets.Length; i++)
  828. {
  829. insets[i] *= (int) screenDensity;
  830. }
  831. return new SafeAreaInsets(insets);
  832. }
  833. #endregion
  834. #region Obsolete
  835. [Obsolete("This API has been deprecated and will be removed in a future release. Please set your SDK key in the AppLovin Integration Manager.")]
  836. public static void SetSdkKey(string sdkKey)
  837. {
  838. MaxUnityPluginClass.CallStatic("setSdkKey", sdkKey);
  839. 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.");
  840. }
  841. #endregion
  842. internal class BackgroundCallbackProxy : AndroidJavaProxy
  843. {
  844. public BackgroundCallbackProxy() : base("com.applovin.mediation.unity.MaxUnityAdManager$BackgroundCallback") { }
  845. public void onEvent(string propsStr)
  846. {
  847. HandleBackgroundCallback(propsStr);
  848. }
  849. }
  850. }
  851. #endif