IronSource.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. public class IronSource : IronSourceIAgent
  6. {
  7. private IronSourceIAgent _platformAgent ;
  8. private static IronSource _instance;
  9. private const string UNITY_PLUGIN_VERSION = "6.7.10";
  10. public const string GENDER_MALE = "male";
  11. public const string GENDER_FEMALE = "female";
  12. public const string GENDER_UNKNOWN = "unknown";
  13. private IronSource ()
  14. {
  15. #if UNITY_EDITOR
  16. _platformAgent = new UnsupportedPlatformAgent();
  17. #elif (UNITY_IPHONE || UNITY_IOS)
  18. _platformAgent = new iOSAgent();
  19. #elif UNITY_ANDROID
  20. _platformAgent = new AndroidAgent ();
  21. #endif
  22. }
  23. #region IronSourceIAgent implementation
  24. public static IronSource Agent {
  25. get {
  26. if (_instance == null) {
  27. _instance = new IronSource ();
  28. }
  29. return _instance;
  30. }
  31. }
  32. public static string pluginVersion ()
  33. {
  34. return UNITY_PLUGIN_VERSION;
  35. }
  36. public static string unityVersion ()
  37. {
  38. return Application.unityVersion;
  39. }
  40. public void reportAppStarted ()
  41. {
  42. _platformAgent.reportAppStarted ();
  43. }
  44. //******************* Base API *******************//
  45. public void onApplicationPause (bool pause)
  46. {
  47. _platformAgent.onApplicationPause (pause);
  48. }
  49. public void setAge (int age)
  50. {
  51. _platformAgent.setAge (age);
  52. }
  53. public void setGender (string gender)
  54. {
  55. if (gender.Equals (GENDER_MALE))
  56. _platformAgent.setGender (GENDER_MALE);
  57. else if (gender.Equals (GENDER_FEMALE))
  58. _platformAgent.setGender (GENDER_FEMALE);
  59. else if (gender.Equals (GENDER_UNKNOWN))
  60. _platformAgent.setGender (GENDER_UNKNOWN);
  61. }
  62. public void setMediationSegment (string segment)
  63. {
  64. _platformAgent.setMediationSegment (segment);
  65. }
  66. public string getAdvertiserId ()
  67. {
  68. return _platformAgent.getAdvertiserId ();
  69. }
  70. public void validateIntegration ()
  71. {
  72. _platformAgent.validateIntegration ();
  73. }
  74. public void shouldTrackNetworkState (bool track)
  75. {
  76. _platformAgent.shouldTrackNetworkState (track);
  77. }
  78. public bool setDynamicUserId (string dynamicUserId)
  79. {
  80. return _platformAgent.setDynamicUserId (dynamicUserId);
  81. }
  82. public void setAdaptersDebug(bool enabled)
  83. {
  84. _platformAgent.setAdaptersDebug (enabled);
  85. }
  86. //******************* SDK Init *******************//
  87. public void setUserId (string userId)
  88. {
  89. _platformAgent.setUserId (userId);
  90. }
  91. public void init (string appKey)
  92. {
  93. _platformAgent.init (appKey);
  94. }
  95. public void init (string appKey, params string[] adUnits)
  96. {
  97. _platformAgent.init (appKey, adUnits);
  98. }
  99. public void initISDemandOnly (string appKey, params string[] adUnits)
  100. {
  101. _platformAgent.initISDemandOnly (appKey, adUnits);
  102. }
  103. //******************* RewardedVideo API *******************//
  104. public void showRewardedVideo ()
  105. {
  106. _platformAgent.showRewardedVideo ();
  107. }
  108. public void showRewardedVideo (string placementName)
  109. {
  110. _platformAgent.showRewardedVideo (placementName);
  111. }
  112. public IronSourcePlacement getPlacementInfo (string placementName)
  113. {
  114. return _platformAgent.getPlacementInfo (placementName);
  115. }
  116. public bool isRewardedVideoAvailable ()
  117. {
  118. return _platformAgent.isRewardedVideoAvailable ();
  119. }
  120. public bool isRewardedVideoPlacementCapped (string placementName)
  121. {
  122. return _platformAgent.isRewardedVideoPlacementCapped (placementName);
  123. }
  124. public void setRewardedVideoServerParams(Dictionary<string, string> parameters)
  125. {
  126. _platformAgent.setRewardedVideoServerParams(parameters);
  127. }
  128. public void clearRewardedVideoServerParams()
  129. {
  130. _platformAgent.clearRewardedVideoServerParams();
  131. }
  132. //******************* RewardedVideo DemandOnly API *******************//
  133. public void showISDemandOnlyRewardedVideo (string instanceId)
  134. {
  135. _platformAgent.showISDemandOnlyRewardedVideo(instanceId);
  136. }
  137. public void showISDemandOnlyRewardedVideo (string instanceId, string placementName)
  138. {
  139. _platformAgent.showISDemandOnlyRewardedVideo(instanceId, placementName);
  140. }
  141. public bool isISDemandOnlyRewardedVideoAvailable (string instanceId)
  142. {
  143. return _platformAgent.isISDemandOnlyRewardedVideoAvailable(instanceId);
  144. }
  145. //******************* Interstitial API *******************//
  146. public void loadInterstitial ()
  147. {
  148. _platformAgent.loadInterstitial ();
  149. }
  150. public void showInterstitial ()
  151. {
  152. _platformAgent.showInterstitial ();
  153. }
  154. public void showInterstitial (string placementName)
  155. {
  156. _platformAgent.showInterstitial (placementName);
  157. }
  158. public bool isInterstitialReady ()
  159. {
  160. return _platformAgent.isInterstitialReady ();
  161. }
  162. public bool isInterstitialPlacementCapped (string placementName)
  163. {
  164. return _platformAgent.isInterstitialPlacementCapped (placementName);
  165. }
  166. //******************* Interstitial DemandOnly API *******************//
  167. public void loadISDemandOnlyInterstitial (string instanceId)
  168. {
  169. _platformAgent.loadISDemandOnlyInterstitial(instanceId);
  170. }
  171. public void showISDemandOnlyInterstitial (string instanceId)
  172. {
  173. _platformAgent.showISDemandOnlyInterstitial(instanceId);
  174. }
  175. public void showISDemandOnlyInterstitial (string instanceId, string placementName)
  176. {
  177. _platformAgent.showISDemandOnlyInterstitial(instanceId, placementName);
  178. }
  179. public bool isISDemandOnlyInterstitialReady (string instanceId)
  180. {
  181. return _platformAgent.isISDemandOnlyInterstitialReady(instanceId);
  182. }
  183. //******************* Offerwall API *******************//
  184. public void showOfferwall ()
  185. {
  186. _platformAgent.showOfferwall ();
  187. }
  188. public void showOfferwall (string placementName)
  189. {
  190. _platformAgent.showOfferwall (placementName);
  191. }
  192. public void getOfferwallCredits ()
  193. {
  194. _platformAgent.getOfferwallCredits ();
  195. }
  196. public bool isOfferwallAvailable ()
  197. {
  198. return _platformAgent.isOfferwallAvailable ();
  199. }
  200. //******************* Banner API *******************//
  201. public void loadBanner (IronSourceBannerSize size, IronSourceBannerPosition position)
  202. {
  203. _platformAgent.loadBanner (size, position);
  204. }
  205. public void loadBanner (IronSourceBannerSize size, IronSourceBannerPosition position, string placementName)
  206. {
  207. _platformAgent.loadBanner (size, position, placementName);
  208. }
  209. public void destroyBanner()
  210. {
  211. _platformAgent.destroyBanner ();
  212. }
  213. public void displayBanner()
  214. {
  215. _platformAgent.displayBanner ();
  216. }
  217. public void hideBanner()
  218. {
  219. _platformAgent.hideBanner ();
  220. }
  221. public bool isBannerPlacementCapped(string placementName)
  222. {
  223. return _platformAgent.isBannerPlacementCapped (placementName);
  224. }
  225. public void setSegment(IronSourceSegment segment)
  226. {
  227. _platformAgent.setSegment (segment);
  228. }
  229. public void setConsent(bool consent)
  230. {
  231. _platformAgent.setConsent(consent);
  232. }
  233. #endregion
  234. }