IronSourceConfig.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System.Runtime.InteropServices;
  2. using UnityEngine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. public class IronSourceConfig
  6. {
  7. private const string unsupportedPlatformStr = "Unsupported Platform";
  8. private static IronSourceConfig _instance;
  9. public static IronSourceConfig Instance {
  10. get {
  11. if (_instance == null) {
  12. _instance = new IronSourceConfig ();
  13. }
  14. return _instance;
  15. }
  16. }
  17. #if UNITY_ANDROID && !UNITY_EDITOR
  18. private static AndroidJavaObject _androidBridge;
  19. private readonly static string AndroidBridge = "com.ironsource.unity.androidbridge.AndroidBridge";
  20. public IronSourceConfig ()
  21. {
  22. using (var pluginClass = new AndroidJavaClass( AndroidBridge ))
  23. _androidBridge = pluginClass.CallStatic<AndroidJavaObject> ("getInstance");
  24. }
  25. //Setters
  26. public void setLanguage (string language)
  27. {
  28. _androidBridge.Call ("setLanguage", language);
  29. }
  30. public void setClientSideCallbacks (bool status)
  31. {
  32. _androidBridge.Call ("setClientSideCallbacks", status);
  33. }
  34. public void setRewardedVideoCustomParams (Dictionary<string,string> rewardedVideoCustomParams)
  35. {
  36. string json = IronSourceJSON.Json.Serialize (rewardedVideoCustomParams);
  37. _androidBridge.Call ("setRewardedVideoCustomParams", json);
  38. }
  39. public void setOfferwallCustomParams (Dictionary<string,string> offerwallCustomParams)
  40. {
  41. string json = IronSourceJSON.Json.Serialize (offerwallCustomParams);
  42. _androidBridge.Call ("setOfferwallCustomParams", json);
  43. }
  44. #elif (UNITY_IPHONE || UNITY_IOS) && !UNITY_EDITOR
  45. [DllImport("__Internal")]
  46. private static extern void CFSetLanguage (string language);
  47. [DllImport("__Internal")]
  48. private static extern void CFSetClientSideCallbacks (bool useClientSideCallbacks);
  49. [DllImport("__Internal")]
  50. private static extern void CFSetRewardedVideoCustomParams (string rewardedVideoCustomParams);
  51. [DllImport("__Internal")]
  52. private static extern void CFSetOfferwallCustomParams (string offerwallCustomParams);
  53. public void setLanguage (string language)
  54. {
  55. CFSetLanguage (language);
  56. }
  57. public void setClientSideCallbacks (bool status)
  58. {
  59. CFSetClientSideCallbacks (status);
  60. }
  61. public void setRewardedVideoCustomParams (Dictionary<string,string> rewardedVideoCustomParams)
  62. {
  63. string json = IronSourceJSON.Json.Serialize (rewardedVideoCustomParams);
  64. CFSetRewardedVideoCustomParams (json);
  65. }
  66. public void setOfferwallCustomParams (Dictionary<string,string> offerwallCustomParams)
  67. {
  68. string json = IronSourceJSON.Json.Serialize (offerwallCustomParams);
  69. CFSetOfferwallCustomParams (json);
  70. }
  71. public IronSourceConfig ()
  72. {
  73. }
  74. #else
  75. public void setLanguage (string language)
  76. {
  77. Debug.Log (unsupportedPlatformStr);
  78. }
  79. public void setClientSideCallbacks (bool status)
  80. {
  81. Debug.Log (unsupportedPlatformStr);
  82. }
  83. public void setRewardedVideoCustomParams (Dictionary<string,string> rewardedVideoCustomParams)
  84. {
  85. Debug.Log (unsupportedPlatformStr);
  86. }
  87. public void setOfferwallCustomParams (Dictionary<string,string> offerwallCustomParams)
  88. {
  89. Debug.Log (unsupportedPlatformStr);
  90. }
  91. public IronSourceConfig ()
  92. {
  93. Debug.Log (unsupportedPlatformStr);
  94. }
  95. #endif
  96. }