IronSourceEvents.cs 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. using UnityEngine;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Globalization;
  7. public class IronSourceEvents : MonoBehaviour
  8. {
  9. private const string ERROR_CODE = "error_code";
  10. private const string ERROR_DESCRIPTION = "error_description";
  11. private const string INSTANCE_ID_KEY = "instanceId";
  12. private const string PLACEMENT_KEY = "placement";
  13. void Awake ()
  14. {
  15. gameObject.name = "IronSourceEvents"; //Change the GameObject name to IronSourceEvents.
  16. DontDestroyOnLoad (gameObject); //Makes the object not be destroyed automatically when loading a new scene.
  17. }
  18. // ******************************* Rewarded Video Events *******************************
  19. private static event Action<IronSourceError> _onRewardedVideoAdShowFailedEvent;
  20. public static event Action<IronSourceError> onRewardedVideoAdShowFailedEvent {
  21. add {
  22. if (_onRewardedVideoAdShowFailedEvent == null || !_onRewardedVideoAdShowFailedEvent.GetInvocationList ().Contains (value)) {
  23. _onRewardedVideoAdShowFailedEvent += value;
  24. }
  25. }
  26. remove {
  27. if (_onRewardedVideoAdShowFailedEvent.GetInvocationList ().Contains (value)) {
  28. _onRewardedVideoAdShowFailedEvent -= value;
  29. }
  30. }
  31. }
  32. public void onRewardedVideoAdShowFailed (string description)
  33. {
  34. if (_onRewardedVideoAdShowFailedEvent != null) {
  35. IronSourceError sse = getErrorFromErrorObject (description);
  36. _onRewardedVideoAdShowFailedEvent (sse);
  37. }
  38. }
  39. private static event Action _onRewardedVideoAdOpenedEvent;
  40. public static event Action onRewardedVideoAdOpenedEvent {
  41. add {
  42. if (_onRewardedVideoAdOpenedEvent == null || !_onRewardedVideoAdOpenedEvent.GetInvocationList ().Contains (value)) {
  43. _onRewardedVideoAdOpenedEvent += value;
  44. }
  45. }
  46. remove {
  47. if (_onRewardedVideoAdOpenedEvent.GetInvocationList ().Contains (value)) {
  48. _onRewardedVideoAdOpenedEvent -= value;
  49. }
  50. }
  51. }
  52. public void onRewardedVideoAdOpened (string empty)
  53. {
  54. if (_onRewardedVideoAdOpenedEvent != null) {
  55. _onRewardedVideoAdOpenedEvent ();
  56. }
  57. }
  58. private static event Action _onRewardedVideoAdClosedEvent;
  59. public static event Action onRewardedVideoAdClosedEvent {
  60. add {
  61. if (_onRewardedVideoAdClosedEvent == null || !_onRewardedVideoAdClosedEvent.GetInvocationList ().Contains (value)) {
  62. _onRewardedVideoAdClosedEvent += value;
  63. }
  64. }
  65. remove {
  66. if (_onRewardedVideoAdClosedEvent.GetInvocationList ().Contains (value)) {
  67. _onRewardedVideoAdClosedEvent -= value;
  68. }
  69. }
  70. }
  71. public void onRewardedVideoAdClosed (string empty)
  72. {
  73. if (_onRewardedVideoAdClosedEvent != null) {
  74. _onRewardedVideoAdClosedEvent ();
  75. }
  76. }
  77. private static event Action _onRewardedVideoAdStartedEvent;
  78. public static event Action onRewardedVideoAdStartedEvent {
  79. add {
  80. if (_onRewardedVideoAdStartedEvent == null || !_onRewardedVideoAdStartedEvent.GetInvocationList ().Contains (value)) {
  81. _onRewardedVideoAdStartedEvent += value;
  82. }
  83. }
  84. remove {
  85. if (_onRewardedVideoAdStartedEvent.GetInvocationList ().Contains (value)) {
  86. _onRewardedVideoAdStartedEvent -= value;
  87. }
  88. }
  89. }
  90. public void onRewardedVideoAdStarted (string empty)
  91. {
  92. if (_onRewardedVideoAdStartedEvent != null) {
  93. _onRewardedVideoAdStartedEvent ();
  94. }
  95. }
  96. private static event Action _onRewardedVideoAdEndedEvent;
  97. public static event Action onRewardedVideoAdEndedEvent {
  98. add {
  99. if (_onRewardedVideoAdEndedEvent == null || !_onRewardedVideoAdEndedEvent.GetInvocationList ().Contains (value)) {
  100. _onRewardedVideoAdEndedEvent += value;
  101. }
  102. }
  103. remove {
  104. if (_onRewardedVideoAdEndedEvent.GetInvocationList ().Contains (value)) {
  105. _onRewardedVideoAdEndedEvent -= value;
  106. }
  107. }
  108. }
  109. public void onRewardedVideoAdEnded (string empty)
  110. {
  111. if (_onRewardedVideoAdEndedEvent != null) {
  112. _onRewardedVideoAdEndedEvent ();
  113. }
  114. }
  115. private static event Action<IronSourcePlacement> _onRewardedVideoAdRewardedEvent;
  116. public static event Action<IronSourcePlacement> onRewardedVideoAdRewardedEvent {
  117. add {
  118. if (_onRewardedVideoAdRewardedEvent == null || !_onRewardedVideoAdRewardedEvent.GetInvocationList ().Contains (value)) {
  119. _onRewardedVideoAdRewardedEvent += value;
  120. }
  121. }
  122. remove {
  123. if (_onRewardedVideoAdRewardedEvent.GetInvocationList ().Contains (value)) {
  124. _onRewardedVideoAdRewardedEvent -= value;
  125. }
  126. }
  127. }
  128. public void onRewardedVideoAdRewarded (string description)
  129. {
  130. if (_onRewardedVideoAdRewardedEvent != null) {
  131. IronSourcePlacement ssp = getPlacementFromObject (description);
  132. _onRewardedVideoAdRewardedEvent (ssp);
  133. }
  134. }
  135. private static event Action<IronSourcePlacement> _onRewardedVideoAdClickedEvent;
  136. public static event Action<IronSourcePlacement> onRewardedVideoAdClickedEvent {
  137. add {
  138. if (_onRewardedVideoAdClickedEvent == null || !_onRewardedVideoAdClickedEvent.GetInvocationList ().Contains (value)) {
  139. _onRewardedVideoAdClickedEvent += value;
  140. }
  141. }
  142. remove {
  143. if (_onRewardedVideoAdClickedEvent.GetInvocationList ().Contains (value)) {
  144. _onRewardedVideoAdClickedEvent -= value;
  145. }
  146. }
  147. }
  148. public void onRewardedVideoAdClicked (string description)
  149. {
  150. if (_onRewardedVideoAdClickedEvent != null) {
  151. IronSourcePlacement ssp = getPlacementFromObject (description);
  152. _onRewardedVideoAdClickedEvent (ssp);
  153. }
  154. }
  155. private static event Action<bool> _onRewardedVideoAvailabilityChangedEvent;
  156. public static event Action<bool> onRewardedVideoAvailabilityChangedEvent {
  157. add {
  158. if (_onRewardedVideoAvailabilityChangedEvent == null || !_onRewardedVideoAvailabilityChangedEvent.GetInvocationList ().Contains (value)) {
  159. _onRewardedVideoAvailabilityChangedEvent += value;
  160. }
  161. }
  162. remove {
  163. if (_onRewardedVideoAvailabilityChangedEvent.GetInvocationList ().Contains (value)) {
  164. _onRewardedVideoAvailabilityChangedEvent -= value;
  165. }
  166. }
  167. }
  168. public void onRewardedVideoAvailabilityChanged (string stringAvailable)
  169. {
  170. bool isAvailable = (stringAvailable == "true") ? true : false;
  171. if (_onRewardedVideoAvailabilityChangedEvent != null)
  172. _onRewardedVideoAvailabilityChangedEvent (isAvailable);
  173. }
  174. // ******************************* RewardedVideo DemandOnly Events *******************************
  175. private static event Action<string,bool> _onRewardedVideoAvailabilityChangedDemandOnlyEvent;
  176. public static event Action<string,bool> onRewardedVideoAvailabilityChangedDemandOnlyEvent {
  177. add {
  178. if (_onRewardedVideoAvailabilityChangedDemandOnlyEvent == null || !_onRewardedVideoAvailabilityChangedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  179. _onRewardedVideoAvailabilityChangedDemandOnlyEvent += value;
  180. }
  181. }
  182. remove {
  183. if (_onRewardedVideoAvailabilityChangedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  184. _onRewardedVideoAvailabilityChangedDemandOnlyEvent -= value;
  185. }
  186. }
  187. }
  188. public void onRewardedVideoAvailabilityChangedDemandOnly (string args)
  189. {
  190. if (_onRewardedVideoAvailabilityChangedDemandOnlyEvent != null && !String.IsNullOrEmpty(args)) {
  191. List<object> argList = IronSourceJSON.Json.Deserialize (args) as List<object>;
  192. bool isAvailable = (argList[1].ToString().ToLower() == "true") ? true : false;
  193. string instanceId = argList[0].ToString();
  194. _onRewardedVideoAvailabilityChangedDemandOnlyEvent (instanceId,isAvailable);
  195. }
  196. }
  197. private static event Action<string> _onRewardedVideoAdOpenedDemandOnlyEvent;
  198. public static event Action<string> onRewardedVideoAdOpenedDemandOnlyEvent {
  199. add {
  200. if (_onRewardedVideoAdOpenedDemandOnlyEvent == null || !_onRewardedVideoAdOpenedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  201. _onRewardedVideoAdOpenedDemandOnlyEvent += value;
  202. }
  203. }
  204. remove {
  205. if (_onRewardedVideoAdOpenedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  206. _onRewardedVideoAdOpenedDemandOnlyEvent -= value;
  207. }
  208. }
  209. }
  210. public void onRewardedVideoAdOpenedDemandOnly (string instanceId)
  211. {
  212. if (_onRewardedVideoAdOpenedDemandOnlyEvent != null) {
  213. _onRewardedVideoAdOpenedDemandOnlyEvent (instanceId);
  214. }
  215. }
  216. private static event Action<string> _onRewardedVideoAdClosedDemandOnlyEvent;
  217. public static event Action<string> onRewardedVideoAdClosedDemandOnlyEvent {
  218. add {
  219. if (_onRewardedVideoAdClosedDemandOnlyEvent == null || !_onRewardedVideoAdClosedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  220. _onRewardedVideoAdClosedDemandOnlyEvent += value;
  221. }
  222. }
  223. remove {
  224. if (_onRewardedVideoAdClosedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  225. _onRewardedVideoAdClosedDemandOnlyEvent -= value;
  226. }
  227. }
  228. }
  229. public void onRewardedVideoAdClosedDemandOnly (string instanceId)
  230. {
  231. if (_onRewardedVideoAdClosedDemandOnlyEvent != null) {
  232. _onRewardedVideoAdClosedDemandOnlyEvent (instanceId);
  233. }
  234. }
  235. private static event Action<string,IronSourcePlacement> _onRewardedVideoAdRewardedDemandOnlyEvent;
  236. public static event Action<string,IronSourcePlacement> onRewardedVideoAdRewardedDemandOnlyEvent {
  237. add {
  238. if (_onRewardedVideoAdRewardedDemandOnlyEvent == null || !_onRewardedVideoAdRewardedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  239. _onRewardedVideoAdRewardedDemandOnlyEvent += value;
  240. }
  241. }
  242. remove {
  243. if (_onRewardedVideoAdRewardedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  244. _onRewardedVideoAdRewardedDemandOnlyEvent -= value;
  245. }
  246. }
  247. }
  248. public void onRewardedVideoAdRewardedDemandOnly (string args)
  249. {
  250. if (_onRewardedVideoAdRewardedDemandOnlyEvent != null && !String.IsNullOrEmpty (args)) {
  251. List<object> argList = IronSourceJSON.Json.Deserialize (args) as List<object>;
  252. string instanceId = argList[0].ToString();
  253. IronSourcePlacement ssp = getPlacementFromObject (argList[1]);
  254. _onRewardedVideoAdRewardedDemandOnlyEvent (instanceId, ssp);
  255. }
  256. }
  257. private static event Action<string,IronSourceError> _onRewardedVideoAdShowFailedDemandOnlyEvent;
  258. public static event Action<string,IronSourceError> onRewardedVideoAdShowFailedDemandOnlyEvent {
  259. add {
  260. if (_onRewardedVideoAdShowFailedDemandOnlyEvent == null || !_onRewardedVideoAdShowFailedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  261. _onRewardedVideoAdShowFailedDemandOnlyEvent += value;
  262. }
  263. }
  264. remove {
  265. if (_onRewardedVideoAdShowFailedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  266. _onRewardedVideoAdShowFailedDemandOnlyEvent -= value;
  267. }
  268. }
  269. }
  270. public void onRewardedVideoAdShowFailedDemandOnly (string args)
  271. {
  272. if (_onRewardedVideoAdShowFailedDemandOnlyEvent != null && !String.IsNullOrEmpty (args)) {
  273. List<object> argList = IronSourceJSON.Json.Deserialize (args) as List<object>;
  274. IronSourceError sse = getErrorFromErrorObject(argList[1]);
  275. string instanceId = argList[0].ToString();
  276. _onRewardedVideoAdShowFailedDemandOnlyEvent (instanceId, sse);
  277. }
  278. }
  279. private static event Action<string,IronSourcePlacement> _onRewardedVideoAdClickedDemandOnlyEvent;
  280. public static event Action<string,IronSourcePlacement> onRewardedVideoAdClickedDemandOnlyEvent {
  281. add {
  282. if (_onRewardedVideoAdClickedDemandOnlyEvent == null || !_onRewardedVideoAdClickedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  283. _onRewardedVideoAdClickedDemandOnlyEvent += value;
  284. }
  285. }
  286. remove {
  287. if (_onRewardedVideoAdClickedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  288. _onRewardedVideoAdClickedDemandOnlyEvent -= value;
  289. }
  290. }
  291. }
  292. public void onRewardedVideoAdClickedDemandOnly (string args)
  293. {
  294. if (_onRewardedVideoAdClickedDemandOnlyEvent != null && !String.IsNullOrEmpty (args)) {
  295. List<object> argList = IronSourceJSON.Json.Deserialize (args) as List<object>;
  296. string instanceId = argList[0].ToString();
  297. IronSourcePlacement ssp = getPlacementFromObject (argList[1]);
  298. _onRewardedVideoAdClickedDemandOnlyEvent (instanceId, ssp);
  299. }
  300. }
  301. // ******************************* Interstitial Events *******************************
  302. private static event Action _onInterstitialAdReadyEvent;
  303. public static event Action onInterstitialAdReadyEvent {
  304. add {
  305. if (_onInterstitialAdReadyEvent == null || !_onInterstitialAdReadyEvent.GetInvocationList ().Contains (value)) {
  306. _onInterstitialAdReadyEvent += value;
  307. }
  308. }
  309. remove {
  310. if (_onInterstitialAdReadyEvent.GetInvocationList ().Contains (value)) {
  311. _onInterstitialAdReadyEvent -= value;
  312. }
  313. }
  314. }
  315. public void onInterstitialAdReady ()
  316. {
  317. if (_onInterstitialAdReadyEvent != null)
  318. _onInterstitialAdReadyEvent ();
  319. }
  320. private static event Action<IronSourceError> _onInterstitialAdLoadFailedEvent;
  321. public static event Action<IronSourceError> onInterstitialAdLoadFailedEvent {
  322. add {
  323. if (_onInterstitialAdLoadFailedEvent == null || !_onInterstitialAdLoadFailedEvent.GetInvocationList ().Contains (value)) {
  324. _onInterstitialAdLoadFailedEvent += value;
  325. }
  326. }
  327. remove {
  328. if (_onInterstitialAdLoadFailedEvent.GetInvocationList ().Contains (value)) {
  329. _onInterstitialAdLoadFailedEvent -= value;
  330. }
  331. }
  332. }
  333. public void onInterstitialAdLoadFailed (string description)
  334. {
  335. if (_onInterstitialAdLoadFailedEvent != null) {
  336. IronSourceError sse = getErrorFromErrorObject (description);
  337. _onInterstitialAdLoadFailedEvent (sse);
  338. }
  339. }
  340. private static event Action _onInterstitialAdOpenedEvent;
  341. public static event Action onInterstitialAdOpenedEvent {
  342. add {
  343. if (_onInterstitialAdOpenedEvent == null || !_onInterstitialAdOpenedEvent.GetInvocationList ().Contains (value)) {
  344. _onInterstitialAdOpenedEvent += value;
  345. }
  346. }
  347. remove {
  348. if (_onInterstitialAdOpenedEvent.GetInvocationList ().Contains (value)) {
  349. _onInterstitialAdOpenedEvent -= value;
  350. }
  351. }
  352. }
  353. public void onInterstitialAdOpened (string empty)
  354. {
  355. if (_onInterstitialAdOpenedEvent != null) {
  356. _onInterstitialAdOpenedEvent ();
  357. }
  358. }
  359. private static event Action _onInterstitialAdClosedEvent;
  360. public static event Action onInterstitialAdClosedEvent {
  361. add {
  362. if (_onInterstitialAdClosedEvent == null || !_onInterstitialAdClosedEvent.GetInvocationList ().Contains (value)) {
  363. _onInterstitialAdClosedEvent += value;
  364. }
  365. }
  366. remove {
  367. if (_onInterstitialAdClosedEvent.GetInvocationList ().Contains (value)) {
  368. _onInterstitialAdClosedEvent -= value;
  369. }
  370. }
  371. }
  372. public void onInterstitialAdClosed (string empty)
  373. {
  374. if (_onInterstitialAdClosedEvent != null) {
  375. _onInterstitialAdClosedEvent ();
  376. }
  377. }
  378. private static event Action _onInterstitialAdShowSucceededEvent;
  379. public static event Action onInterstitialAdShowSucceededEvent {
  380. add {
  381. if (_onInterstitialAdShowSucceededEvent == null || !_onInterstitialAdShowSucceededEvent.GetInvocationList ().Contains (value)) {
  382. _onInterstitialAdShowSucceededEvent += value;
  383. }
  384. }
  385. remove {
  386. if (_onInterstitialAdShowSucceededEvent.GetInvocationList ().Contains (value)) {
  387. _onInterstitialAdShowSucceededEvent -= value;
  388. }
  389. }
  390. }
  391. public void onInterstitialAdShowSucceeded (string empty)
  392. {
  393. if (_onInterstitialAdShowSucceededEvent != null) {
  394. _onInterstitialAdShowSucceededEvent ();
  395. }
  396. }
  397. private static event Action<IronSourceError> _onInterstitialAdShowFailedEvent;
  398. public static event Action<IronSourceError> onInterstitialAdShowFailedEvent {
  399. add {
  400. if (_onInterstitialAdShowFailedEvent == null || !_onInterstitialAdShowFailedEvent.GetInvocationList ().Contains (value)) {
  401. _onInterstitialAdShowFailedEvent += value;
  402. }
  403. }
  404. remove {
  405. if (_onInterstitialAdShowFailedEvent.GetInvocationList ().Contains (value)) {
  406. _onInterstitialAdShowFailedEvent -= value;
  407. }
  408. }
  409. }
  410. public void onInterstitialAdShowFailed (string description)
  411. {
  412. if (_onInterstitialAdShowFailedEvent != null) {
  413. IronSourceError sse = getErrorFromErrorObject (description);
  414. _onInterstitialAdShowFailedEvent (sse);
  415. }
  416. }
  417. private static event Action _onInterstitialAdClickedEvent;
  418. public static event Action onInterstitialAdClickedEvent {
  419. add {
  420. if (_onInterstitialAdClickedEvent == null || !_onInterstitialAdClickedEvent.GetInvocationList ().Contains (value)) {
  421. _onInterstitialAdClickedEvent += value;
  422. }
  423. }
  424. remove {
  425. if (_onInterstitialAdClickedEvent.GetInvocationList ().Contains (value)) {
  426. _onInterstitialAdClickedEvent -= value;
  427. }
  428. }
  429. }
  430. public void onInterstitialAdClicked (string empty)
  431. {
  432. if (_onInterstitialAdClickedEvent != null) {
  433. _onInterstitialAdClickedEvent ();
  434. }
  435. }
  436. // ******************************* Interstitial DemanOnly Events *******************************
  437. private static event Action<string> _onInterstitialAdReadyDemandOnlyEvent;
  438. public static event Action<string> onInterstitialAdReadyDemandOnlyEvent {
  439. add {
  440. if (_onInterstitialAdReadyDemandOnlyEvent == null || !_onInterstitialAdReadyDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  441. _onInterstitialAdReadyDemandOnlyEvent += value;
  442. }
  443. }
  444. remove {
  445. if (_onInterstitialAdReadyDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  446. _onInterstitialAdReadyDemandOnlyEvent -= value;
  447. }
  448. }
  449. }
  450. public void onInterstitialAdReadyDemandOnly (string instanceId)
  451. {
  452. if (_onInterstitialAdReadyDemandOnlyEvent != null)
  453. _onInterstitialAdReadyDemandOnlyEvent (instanceId);
  454. }
  455. private static event Action<string,IronSourceError> _onInterstitialAdLoadFailedDemandOnlyEvent;
  456. public static event Action<string,IronSourceError> onInterstitialAdLoadFailedDemandOnlyEvent {
  457. add {
  458. if (_onInterstitialAdLoadFailedDemandOnlyEvent == null || !_onInterstitialAdLoadFailedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  459. _onInterstitialAdLoadFailedDemandOnlyEvent += value;
  460. }
  461. }
  462. remove {
  463. if (_onInterstitialAdLoadFailedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  464. _onInterstitialAdLoadFailedDemandOnlyEvent -= value;
  465. }
  466. }
  467. }
  468. public void onInterstitialAdLoadFailedDemandOnly (string args)
  469. {
  470. if (_onInterstitialAdLoadFailedDemandOnlyEvent != null && !String.IsNullOrEmpty(args)) {
  471. List<object> argList = IronSourceJSON.Json.Deserialize (args) as List<object>;
  472. IronSourceError err = getErrorFromErrorObject(argList[1]);
  473. string instanceId = argList[0].ToString();
  474. _onInterstitialAdLoadFailedDemandOnlyEvent (instanceId, err);
  475. }
  476. }
  477. private static event Action<string> _onInterstitialAdOpenedDemandOnlyEvent;
  478. public static event Action<string> onInterstitialAdOpenedDemandOnlyEvent {
  479. add {
  480. if (_onInterstitialAdOpenedDemandOnlyEvent == null || !_onInterstitialAdOpenedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  481. _onInterstitialAdOpenedDemandOnlyEvent += value;
  482. }
  483. }
  484. remove {
  485. if (_onInterstitialAdOpenedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  486. _onInterstitialAdOpenedDemandOnlyEvent -= value;
  487. }
  488. }
  489. }
  490. public void onInterstitialAdOpenedDemandOnly (string instanceId)
  491. {
  492. if (_onInterstitialAdOpenedDemandOnlyEvent != null) {
  493. _onInterstitialAdOpenedDemandOnlyEvent (instanceId);
  494. }
  495. }
  496. private static event Action<string> _onInterstitialAdClosedDemandOnlyEvent;
  497. public static event Action<string> onInterstitialAdClosedDemandOnlyEvent {
  498. add {
  499. if (_onInterstitialAdClosedDemandOnlyEvent == null || !_onInterstitialAdClosedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  500. _onInterstitialAdClosedDemandOnlyEvent += value;
  501. }
  502. }
  503. remove {
  504. if (_onInterstitialAdClosedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  505. _onInterstitialAdClosedDemandOnlyEvent -= value;
  506. }
  507. }
  508. }
  509. public void onInterstitialAdClosedDemandOnly (string instanceId)
  510. {
  511. if (_onInterstitialAdClosedDemandOnlyEvent != null) {
  512. _onInterstitialAdClosedDemandOnlyEvent (instanceId);
  513. }
  514. }
  515. private static event Action<string> _onInterstitialAdShowSucceededDemandOnlyEvent;
  516. public static event Action<string> onInterstitialAdShowSucceededDemandOnlyEvent {
  517. add {
  518. if (_onInterstitialAdShowSucceededDemandOnlyEvent == null || !_onInterstitialAdShowSucceededDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  519. _onInterstitialAdShowSucceededDemandOnlyEvent += value;
  520. }
  521. }
  522. remove {
  523. if (_onInterstitialAdShowSucceededDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  524. _onInterstitialAdShowSucceededDemandOnlyEvent -= value;
  525. }
  526. }
  527. }
  528. public void onInterstitialAdShowSucceededDemandOnly (string instanceId)
  529. {
  530. if (_onInterstitialAdShowSucceededDemandOnlyEvent != null) {
  531. _onInterstitialAdShowSucceededDemandOnlyEvent (instanceId);
  532. }
  533. }
  534. private static event Action<string, IronSourceError> _onInterstitialAdShowFailedDemandOnlyEvent;
  535. public static event Action<string, IronSourceError> onInterstitialAdShowFailedDemandOnlyEvent {
  536. add {
  537. if (_onInterstitialAdShowFailedDemandOnlyEvent == null || !_onInterstitialAdShowFailedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  538. _onInterstitialAdShowFailedDemandOnlyEvent += value;
  539. }
  540. }
  541. remove {
  542. if (_onInterstitialAdShowFailedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  543. _onInterstitialAdShowFailedDemandOnlyEvent -= value;
  544. }
  545. }
  546. }
  547. public void onInterstitialAdShowFailedDemandOnly (string args)
  548. {
  549. if (_onInterstitialAdLoadFailedDemandOnlyEvent != null && !String.IsNullOrEmpty (args)) {
  550. List<object> argList = IronSourceJSON.Json.Deserialize (args) as List<object>;
  551. IronSourceError sse = getErrorFromErrorObject(argList[1]);
  552. string instanceId = argList[0].ToString();
  553. _onInterstitialAdShowFailedDemandOnlyEvent (instanceId, sse);
  554. }
  555. }
  556. private static event Action<string> _onInterstitialAdClickedDemandOnlyEvent;
  557. public static event Action<string> onInterstitialAdClickedDemandOnlyEvent {
  558. add {
  559. if (_onInterstitialAdClickedDemandOnlyEvent == null || !_onInterstitialAdClickedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  560. _onInterstitialAdClickedDemandOnlyEvent += value;
  561. }
  562. }
  563. remove {
  564. if (_onInterstitialAdClickedDemandOnlyEvent.GetInvocationList ().Contains (value)) {
  565. _onInterstitialAdClickedDemandOnlyEvent -= value;
  566. }
  567. }
  568. }
  569. public void onInterstitialAdClickedDemandOnly (string instanceId)
  570. {
  571. if (_onInterstitialAdClickedDemandOnlyEvent != null) {
  572. _onInterstitialAdClickedDemandOnlyEvent (instanceId);
  573. }
  574. }
  575. // ******************************* Rewarded Interstitial Events *******************************
  576. private static event Action _onInterstitialAdRewardedEvent;
  577. public static event Action onInterstitialAdRewardedEvent {
  578. add {
  579. if (_onInterstitialAdRewardedEvent == null || !_onInterstitialAdRewardedEvent.GetInvocationList ().Contains (value)) {
  580. _onInterstitialAdRewardedEvent += value;
  581. }
  582. }
  583. remove {
  584. if (_onInterstitialAdRewardedEvent.GetInvocationList ().Contains (value)) {
  585. _onInterstitialAdRewardedEvent -= value;
  586. }
  587. }
  588. }
  589. public void onInterstitialAdRewarded (string empty)
  590. {
  591. if (_onInterstitialAdRewardedEvent != null) {
  592. _onInterstitialAdRewardedEvent ();
  593. }
  594. }
  595. // ******************************* Offerwall Events *******************************
  596. private static event Action _onOfferwallOpenedEvent;
  597. public static event Action onOfferwallOpenedEvent {
  598. add {
  599. if (_onOfferwallOpenedEvent == null || !_onOfferwallOpenedEvent.GetInvocationList ().Contains (value)) {
  600. _onOfferwallOpenedEvent += value;
  601. }
  602. }
  603. remove {
  604. if (_onOfferwallOpenedEvent.GetInvocationList ().Contains (value)) {
  605. _onOfferwallOpenedEvent -= value;
  606. }
  607. }
  608. }
  609. public void onOfferwallOpened (string empty)
  610. {
  611. if (_onOfferwallOpenedEvent != null) {
  612. _onOfferwallOpenedEvent ();
  613. }
  614. }
  615. private static event Action<IronSourceError> _onOfferwallShowFailedEvent;
  616. public static event Action<IronSourceError> onOfferwallShowFailedEvent {
  617. add {
  618. if (_onOfferwallShowFailedEvent == null || !_onOfferwallShowFailedEvent.GetInvocationList ().Contains (value)) {
  619. _onOfferwallShowFailedEvent += value;
  620. }
  621. }
  622. remove {
  623. if (_onOfferwallShowFailedEvent.GetInvocationList ().Contains (value)) {
  624. _onOfferwallShowFailedEvent -= value;
  625. }
  626. }
  627. }
  628. public void onOfferwallShowFailed (string description)
  629. {
  630. if (_onOfferwallShowFailedEvent != null) {
  631. IronSourceError sse = getErrorFromErrorObject (description);
  632. _onOfferwallShowFailedEvent (sse);
  633. }
  634. }
  635. private static event Action _onOfferwallClosedEvent;
  636. public static event Action onOfferwallClosedEvent {
  637. add {
  638. if (_onOfferwallClosedEvent == null || !_onOfferwallClosedEvent.GetInvocationList ().Contains (value)) {
  639. _onOfferwallClosedEvent += value;
  640. }
  641. }
  642. remove {
  643. if (_onOfferwallClosedEvent.GetInvocationList ().Contains (value)) {
  644. _onOfferwallClosedEvent -= value;
  645. }
  646. }
  647. }
  648. public void onOfferwallClosed (string empty)
  649. {
  650. if (_onOfferwallClosedEvent != null) {
  651. _onOfferwallClosedEvent ();
  652. }
  653. }
  654. private static event Action<IronSourceError> _onGetOfferwallCreditsFailedEvent;
  655. public static event Action<IronSourceError> onGetOfferwallCreditsFailedEvent {
  656. add {
  657. if (_onGetOfferwallCreditsFailedEvent == null || !_onGetOfferwallCreditsFailedEvent.GetInvocationList ().Contains (value)) {
  658. _onGetOfferwallCreditsFailedEvent += value;
  659. }
  660. }
  661. remove {
  662. if (_onGetOfferwallCreditsFailedEvent.GetInvocationList ().Contains (value)) {
  663. _onGetOfferwallCreditsFailedEvent -= value;
  664. }
  665. }
  666. }
  667. public void onGetOfferwallCreditsFailed (string description)
  668. {
  669. if (_onGetOfferwallCreditsFailedEvent != null) {
  670. IronSourceError sse = getErrorFromErrorObject (description);
  671. _onGetOfferwallCreditsFailedEvent (sse);
  672. }
  673. }
  674. private static event Action<Dictionary<string,object>> _onOfferwallAdCreditedEvent;
  675. public static event Action<Dictionary<string,object>> onOfferwallAdCreditedEvent {
  676. add {
  677. if (_onOfferwallAdCreditedEvent == null || !_onOfferwallAdCreditedEvent.GetInvocationList ().Contains (value)) {
  678. _onOfferwallAdCreditedEvent += value;
  679. }
  680. }
  681. remove {
  682. if (_onOfferwallAdCreditedEvent.GetInvocationList ().Contains (value)) {
  683. _onOfferwallAdCreditedEvent -= value;
  684. }
  685. }
  686. }
  687. public void onOfferwallAdCredited (string json)
  688. {
  689. if (_onOfferwallAdCreditedEvent != null)
  690. _onOfferwallAdCreditedEvent (IronSourceJSON.Json.Deserialize (json) as Dictionary<string,object>);
  691. }
  692. private static event Action<bool> _onOfferwallAvailableEvent;
  693. public static event Action<bool> onOfferwallAvailableEvent {
  694. add {
  695. if (_onOfferwallAvailableEvent == null || !_onOfferwallAvailableEvent.GetInvocationList ().Contains (value)) {
  696. _onOfferwallAvailableEvent += value;
  697. }
  698. }
  699. remove {
  700. if (_onOfferwallAvailableEvent.GetInvocationList ().Contains (value)) {
  701. _onOfferwallAvailableEvent -= value;
  702. }
  703. }
  704. }
  705. public void onOfferwallAvailable (string stringAvailable)
  706. {
  707. bool isAvailable = (stringAvailable == "true") ? true : false;
  708. if (_onOfferwallAvailableEvent != null)
  709. _onOfferwallAvailableEvent (isAvailable);
  710. }
  711. // ******************************* Banner Events *******************************
  712. private static event Action _onBannerAdLoadedEvent;
  713. public static event Action onBannerAdLoadedEvent {
  714. add {
  715. if (_onBannerAdLoadedEvent == null || !_onBannerAdLoadedEvent.GetInvocationList ().Contains (value)) {
  716. _onBannerAdLoadedEvent += value;
  717. }
  718. }
  719. remove {
  720. if (_onBannerAdLoadedEvent.GetInvocationList ().Contains (value)) {
  721. _onBannerAdLoadedEvent -= value;
  722. }
  723. }
  724. }
  725. public void onBannerAdLoaded ()
  726. {
  727. if (_onBannerAdLoadedEvent != null)
  728. _onBannerAdLoadedEvent ();
  729. }
  730. private static event Action<IronSourceError> _onBannerAdLoadFailedEvent;
  731. public static event Action<IronSourceError> onBannerAdLoadFailedEvent {
  732. add {
  733. if (_onBannerAdLoadFailedEvent == null || !_onBannerAdLoadFailedEvent.GetInvocationList ().Contains (value)) {
  734. _onBannerAdLoadFailedEvent += value;
  735. }
  736. }
  737. remove {
  738. if (_onBannerAdLoadFailedEvent.GetInvocationList ().Contains (value)) {
  739. _onBannerAdLoadFailedEvent -= value;
  740. }
  741. }
  742. }
  743. public void onBannerAdLoadFailed (string description)
  744. {
  745. if (_onBannerAdLoadFailedEvent != null) {
  746. IronSourceError sse = getErrorFromErrorObject (description);
  747. _onBannerAdLoadFailedEvent (sse);
  748. }
  749. }
  750. private static event Action _onBannerAdClickedEvent;
  751. public static event Action onBannerAdClickedEvent {
  752. add {
  753. if (_onBannerAdClickedEvent == null || !_onBannerAdClickedEvent.GetInvocationList ().Contains (value)) {
  754. _onBannerAdClickedEvent += value;
  755. }
  756. }
  757. remove {
  758. if (_onBannerAdClickedEvent.GetInvocationList ().Contains (value)) {
  759. _onBannerAdClickedEvent -= value;
  760. }
  761. }
  762. }
  763. public void onBannerAdClicked ()
  764. {
  765. if (_onBannerAdClickedEvent != null)
  766. _onBannerAdClickedEvent ();
  767. }
  768. private static event Action _onBannerAdScreenPresentedEvent;
  769. public static event Action onBannerAdScreenPresentedEvent {
  770. add {
  771. if (_onBannerAdScreenPresentedEvent == null || !_onBannerAdScreenPresentedEvent.GetInvocationList ().Contains (value)) {
  772. _onBannerAdScreenPresentedEvent += value;
  773. }
  774. }
  775. remove {
  776. if (_onBannerAdScreenPresentedEvent.GetInvocationList ().Contains (value)) {
  777. _onBannerAdScreenPresentedEvent -= value;
  778. }
  779. }
  780. }
  781. public void onBannerAdScreenPresented ()
  782. {
  783. if (_onBannerAdScreenPresentedEvent != null)
  784. _onBannerAdScreenPresentedEvent ();
  785. }
  786. private static event Action _onBannerAdScreenDismissedEvent;
  787. public static event Action onBannerAdScreenDismissedEvent {
  788. add {
  789. if (_onBannerAdScreenDismissedEvent == null || !_onBannerAdScreenDismissedEvent.GetInvocationList ().Contains (value)) {
  790. _onBannerAdScreenDismissedEvent += value;
  791. }
  792. }
  793. remove {
  794. if (_onBannerAdScreenDismissedEvent.GetInvocationList ().Contains (value)) {
  795. _onBannerAdScreenDismissedEvent -= value;
  796. }
  797. }
  798. }
  799. public void onBannerAdScreenDismissed ()
  800. {
  801. if (_onBannerAdScreenDismissedEvent != null)
  802. _onBannerAdScreenDismissedEvent ();
  803. }
  804. private static event Action _onBannerAdLeftApplicationEvent;
  805. public static event Action onBannerAdLeftApplicationEvent {
  806. add {
  807. if (_onBannerAdLeftApplicationEvent == null || !_onBannerAdLeftApplicationEvent.GetInvocationList ().Contains (value)) {
  808. _onBannerAdLeftApplicationEvent += value;
  809. }
  810. }
  811. remove {
  812. if (_onBannerAdLeftApplicationEvent.GetInvocationList ().Contains (value)) {
  813. _onBannerAdLeftApplicationEvent -= value;
  814. }
  815. }
  816. }
  817. public void onBannerAdLeftApplication ()
  818. {
  819. if (_onBannerAdLeftApplicationEvent != null)
  820. _onBannerAdLeftApplicationEvent ();
  821. }
  822. private static event Action<string> _onSegmentReceivedEvent;
  823. public static event Action<string> onSegmentReceivedEvent {
  824. add {
  825. if (_onSegmentReceivedEvent == null || !_onSegmentReceivedEvent.GetInvocationList ().Contains (value)) {
  826. _onSegmentReceivedEvent += value;
  827. }
  828. }
  829. remove {
  830. if (_onSegmentReceivedEvent.GetInvocationList ().Contains (value)) {
  831. _onSegmentReceivedEvent -= value;
  832. }
  833. }
  834. }
  835. public void onSegmentReceived (string segmentName)
  836. {
  837. if (_onSegmentReceivedEvent != null)
  838. _onSegmentReceivedEvent (segmentName);
  839. }
  840. // ******************************* Helper methods *******************************
  841. private IronSourceError getErrorFromErrorObject (object descriptionObject)
  842. {
  843. Dictionary<string,object> error = null;
  844. if (descriptionObject is IDictionary) {
  845. error = descriptionObject as Dictionary<string,object>;
  846. }
  847. else if (descriptionObject is String && !String.IsNullOrEmpty (descriptionObject.ToString())) {
  848. error = IronSourceJSON.Json.Deserialize (descriptionObject.ToString()) as Dictionary<string,object>;
  849. }
  850. IronSourceError sse = new IronSourceError (-1, "");
  851. if (error != null && error.Count > 0) {
  852. int eCode = Convert.ToInt32 (error [ERROR_CODE].ToString ());
  853. string eDescription = error [ERROR_DESCRIPTION].ToString ();
  854. sse = new IronSourceError (eCode, eDescription);
  855. }
  856. return sse;
  857. }
  858. private IronSourcePlacement getPlacementFromObject (object placementObject)
  859. {
  860. Dictionary<string,object> placementJSON = null;
  861. if (placementObject is IDictionary) {
  862. placementJSON = placementObject as Dictionary<string,object>;
  863. }
  864. else if (placementObject is String) {
  865. placementJSON = IronSourceJSON.Json.Deserialize (placementObject.ToString()) as Dictionary<string,object>;
  866. }
  867. IronSourcePlacement ssp = null;
  868. if (placementJSON != null && placementJSON.Count > 0) {
  869. int rewardAmount = Convert.ToInt32 (placementJSON ["placement_reward_amount"].ToString ());
  870. string rewardName = placementJSON ["placement_reward_name"].ToString ();
  871. string placementName = placementJSON ["placement_name"].ToString ();
  872. ssp = new IronSourcePlacement (placementName, rewardName, rewardAmount);
  873. }
  874. return ssp;
  875. }
  876. }