AnySDK.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Runtime.InteropServices;
  4. using System;
  5. using System.Text;
  6. namespace anysdk
  7. {
  8. public class AnySDK
  9. {
  10. private static AnySDK _instance;
  11. public static AnySDK getInstance() {
  12. if( null == _instance ) {
  13. _instance = new AnySDK();
  14. }
  15. return _instance;
  16. }
  17. /**
  18. @breif the init of AgentManager
  19. @param the appKey of anysdk
  20. @param the appSecret of anysdk
  21. @param the privateKey of anysdk
  22. @param the url of oauthLoginServer
  23. @warning Must invoke this interface before loadALLPlugin
  24. */
  25. public void init(string appKey, string appSecret, string privateKey, string authLoginServer)
  26. {
  27. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  28. AnySDK_nativeInitPluginSystem (appKey, appSecret, privateKey, authLoginServer);
  29. #else
  30. Debug.Log("This platform does not support!");
  31. #endif
  32. }
  33. [Obsolete("This interface is obsolete!",false)]
  34. public void loadALLPlugin()
  35. {
  36. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  37. Debug.Log("This interface is obsolete!");
  38. #else
  39. Debug.Log("This platform does not support!");
  40. #endif
  41. }
  42. /**
  43. @brief Get custom param
  44. @return return value is custom param for channel.
  45. */
  46. public string getCustomParam()
  47. {
  48. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  49. StringBuilder customParam = new StringBuilder();
  50. customParam.Capacity = AnySDKUtil.MAX_CAPACITY_NUM;
  51. AnySDK_nativeGetCustomParam (customParam);
  52. return customParam.ToString();
  53. #else
  54. Debug.Log("This platform does not support!");
  55. return "";
  56. #endif
  57. }
  58. /**
  59. @brief Get channel ID
  60. @return return value is channel ID.
  61. */
  62. public string getChannelId()
  63. {
  64. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  65. StringBuilder channelId = new StringBuilder();
  66. channelId.Capacity = AnySDKUtil.MAX_CAPACITY_NUM;
  67. AnySDK_nativeGetChannelId (channelId);
  68. return channelId.ToString();
  69. #else
  70. Debug.Log("This platform does not support!");
  71. return "";
  72. #endif
  73. }
  74. /**
  75. @brief Get framework version
  76. @return return value is framework version.
  77. */
  78. public string getFrameworkVersion()
  79. {
  80. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  81. StringBuilder version = new StringBuilder();
  82. version.Capacity = AnySDKUtil.MAX_CAPACITY_NUM;
  83. AnySDK_nativeGetFrameworkVersion (version);
  84. return version.ToString();
  85. #else
  86. Debug.Log("This platform does not support!");
  87. return "";
  88. #endif
  89. }
  90. /**
  91. @brief release the anysdk
  92. */
  93. public void release()
  94. {
  95. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  96. AnySDK_nativeRelease ();
  97. #else
  98. Debug.Log("This platform does not support!");
  99. #endif
  100. }
  101. /**
  102. *
  103. * @Title: isUserPluginExist
  104. * @Description: is UserPlugin Exist
  105. * @param @return true or false
  106. * @return boolean
  107. */
  108. public bool isUserPluginExist()
  109. {
  110. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  111. return AnySDK_nativeIsUserPluginExist ();
  112. #else
  113. Debug.Log("This platform does not support!");
  114. return false;
  115. #endif
  116. }
  117. /**
  118. *
  119. * @Title: isIAPPluginExist
  120. * @Description: is IAPPlugin Exist
  121. * @param @return true or false
  122. * @return boolean
  123. */
  124. public bool isIAPPluginExist()
  125. {
  126. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  127. return AnySDK_nativeIsIAPPluginExist ();
  128. #else
  129. Debug.Log("This platform does not support!");
  130. return false;
  131. #endif
  132. }
  133. /**
  134. *
  135. * @Title: isAdsPluginExist
  136. * @Description: is AdsPlugin Exist
  137. * @param @return true or false
  138. * @return boolean
  139. */
  140. public bool isAdsPluginExist()
  141. {
  142. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  143. return AnySDK_nativeIsAdsPluginExist ();
  144. #else
  145. Debug.Log("This platform does not support!");
  146. return false;
  147. #endif
  148. }
  149. /**
  150. *
  151. * @Title: isAnalyticsPluginExist
  152. * @Description: is AnalyticsPlugin Exist
  153. * @param @return true or false
  154. * @return boolean
  155. */
  156. public bool isAnalyticsPluginExist()
  157. {
  158. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  159. return AnySDK_nativeIsAnalyticsPluginExist ();
  160. #else
  161. Debug.Log("This platform does not support!");
  162. return false;
  163. #endif
  164. }
  165. /**
  166. *
  167. * @Title: isPushPluginExist
  168. * @Description: is PushPlugin Exist
  169. * @param @return true or false
  170. * @return boolean
  171. */
  172. public bool isPushPluginExist()
  173. {
  174. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  175. return AnySDK_nativeIsPushPluginExist ();
  176. #else
  177. Debug.Log("This platform does not support!");
  178. return false;
  179. #endif
  180. }
  181. /**
  182. *
  183. * @Title: isSharePluginExist
  184. * @Description: is SharePlugin Exist
  185. * @param @return true or false
  186. * @return boolean
  187. */
  188. public bool isSharePluginExist()
  189. {
  190. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  191. return AnySDK_nativeIsSharePluginExist ();
  192. #else
  193. Debug.Log("This platform does not support!");
  194. return false;
  195. #endif
  196. }
  197. /**
  198. *
  199. * @Title: isSocialPluginExist
  200. * @Description: is SocialPlugin Exist
  201. * @param @return true or false
  202. * @return boolean
  203. */
  204. public bool isSocialPluginExist()
  205. {
  206. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  207. return AnySDK_nativeIsSocialPluginExist ();
  208. #else
  209. Debug.Log("This platform does not support!");
  210. return false;
  211. #endif
  212. }
  213. /**
  214. *
  215. * @Title: isCustomPluginExist
  216. * @Description: is CustomPlugin Exist
  217. * @param @return true or false
  218. * @return boolean
  219. */
  220. public bool isCustomPluginExist()
  221. {
  222. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  223. return AnySDK_nativeIsCustomPluginExist ();
  224. #else
  225. Debug.Log("This platform does not support!");
  226. return false;
  227. #endif
  228. }
  229. /**
  230. *
  231. * @Title: isRECPluginExist
  232. * @Description: is RECPlugin Exist
  233. * @param @return true or false
  234. * @return boolean
  235. */
  236. public bool isRECPluginExist()
  237. {
  238. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  239. return AnySDK_nativeIsRECPluginExist ();
  240. #else
  241. Debug.Log("This platform does not support!");
  242. return false;
  243. #endif
  244. }
  245. /**
  246. *
  247. * @Title: isCrashPluginExist
  248. * @Description: is CrashPlugin Exist
  249. * @param @return true or false
  250. * @return boolean
  251. */
  252. public bool isCrashPluginExist()
  253. {
  254. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  255. return AnySDK_nativeIsCrashPluginExist ();
  256. #else
  257. Debug.Log("This platform does not support!");
  258. return false;
  259. #endif
  260. }
  261. /**
  262. *
  263. * @Title: isAdTrackingPluginExist
  264. * @Description: is AdTrackingPlugin Exist
  265. * @param @return true or false
  266. * @return boolean
  267. */
  268. public bool isAdTrackingPluginExist()
  269. {
  270. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  271. return AnySDK_nativeIsAdTrackingPluginExist ();
  272. #else
  273. Debug.Log("This platform does not support!");
  274. return false;
  275. #endif
  276. }
  277. /**
  278. *
  279. * @Title: setIsAnaylticsEnabled
  280. * @Description: choose to open or close
  281. * @param @param enabled true or false
  282. * @return void
  283. */
  284. public void setIsAnaylticsEnabled(bool enabled)
  285. {
  286. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  287. AnySDK_nativeSetIsAnaylticsEnabled (enabled);
  288. #else
  289. Debug.Log("This platform does not support!");
  290. #endif
  291. }
  292. /**
  293. *
  294. * @Title: isAnaylticsEnabled
  295. * @Description: the status of Anayltics
  296. * @param @return true or false
  297. * @return boolean
  298. */
  299. public bool isAnaylticsEnabled()
  300. {
  301. #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
  302. return AnySDK_nativeIsAnaylticsEnabled ();
  303. #else
  304. Debug.Log("This platform does not support!");
  305. return false;
  306. #endif
  307. }
  308. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  309. private static extern void AnySDK_nativeInitPluginSystem(string appKey, string appSecret, string privateKey, string authLoginServer);
  310. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  311. private static extern void AnySDK_nativeLoadPlugins();
  312. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  313. private static extern void AnySDK_nativeGetChannelId(StringBuilder channelId);
  314. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  315. private static extern void AnySDK_nativeGetFrameworkVersion(StringBuilder version);
  316. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  317. private static extern void AnySDK_nativeGetCustomParam(StringBuilder customParam);
  318. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  319. private static extern void AnySDK_nativeRelease();
  320. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  321. private static extern bool AnySDK_nativeIsUserPluginExist();
  322. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  323. private static extern bool AnySDK_nativeIsIAPPluginExist();
  324. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  325. private static extern bool AnySDK_nativeIsAdsPluginExist();
  326. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  327. private static extern bool AnySDK_nativeIsAnalyticsPluginExist();
  328. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  329. private static extern bool AnySDK_nativeIsSharePluginExist();
  330. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  331. private static extern bool AnySDK_nativeIsSocialPluginExist();
  332. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  333. private static extern bool AnySDK_nativeIsPushPluginExist();
  334. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  335. private static extern bool AnySDK_nativeIsAdTrackingPluginExist();
  336. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  337. private static extern bool AnySDK_nativeIsCustomPluginExist();
  338. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  339. private static extern bool AnySDK_nativeIsRECPluginExist();
  340. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  341. private static extern bool AnySDK_nativeIsCrashPluginExist();
  342. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  343. private static extern void AnySDK_nativeSetIsAnaylticsEnabled(bool enabled);
  344. [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
  345. private static extern bool AnySDK_nativeIsAnaylticsEnabled();
  346. }
  347. }