123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- using UnityEngine;
- using System.Collections;
- using System.Runtime.InteropServices;
- using System;
- using System.Text;
- namespace anysdk
- {
- public class AnySDK
- {
- private static AnySDK _instance;
-
- public static AnySDK getInstance() {
- if( null == _instance ) {
- _instance = new AnySDK();
- }
- return _instance;
- }
- /**
- @breif the init of AgentManager
- @param the appKey of anysdk
- @param the appSecret of anysdk
- @param the privateKey of anysdk
- @param the url of oauthLoginServer
- @warning Must invoke this interface before loadALLPlugin
- */
- public void init(string appKey, string appSecret, string privateKey, string authLoginServer)
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- AnySDK_nativeInitPluginSystem (appKey, appSecret, privateKey, authLoginServer);
- #else
- Debug.Log("This platform does not support!");
- #endif
- }
- [Obsolete("This interface is obsolete!",false)]
- public void loadALLPlugin()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- Debug.Log("This interface is obsolete!");
- #else
- Debug.Log("This platform does not support!");
- #endif
- }
- /**
- @brief Get custom param
- @return return value is custom param for channel.
- */
- public string getCustomParam()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- StringBuilder customParam = new StringBuilder();
- customParam.Capacity = AnySDKUtil.MAX_CAPACITY_NUM;
- AnySDK_nativeGetCustomParam (customParam);
- return customParam.ToString();
- #else
- Debug.Log("This platform does not support!");
- return "";
- #endif
- }
- /**
- @brief Get channel ID
- @return return value is channel ID.
- */
- public string getChannelId()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- StringBuilder channelId = new StringBuilder();
- channelId.Capacity = AnySDKUtil.MAX_CAPACITY_NUM;
- AnySDK_nativeGetChannelId (channelId);
- return channelId.ToString();
- #else
- Debug.Log("This platform does not support!");
- return "";
- #endif
- }
- /**
- @brief Get framework version
- @return return value is framework version.
- */
- public string getFrameworkVersion()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- StringBuilder version = new StringBuilder();
- version.Capacity = AnySDKUtil.MAX_CAPACITY_NUM;
- AnySDK_nativeGetFrameworkVersion (version);
- return version.ToString();
- #else
- Debug.Log("This platform does not support!");
- return "";
- #endif
- }
- /**
- @brief release the anysdk
- */
- public void release()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- AnySDK_nativeRelease ();
- #else
- Debug.Log("This platform does not support!");
- #endif
- }
- /**
- *
- * @Title: isUserPluginExist
- * @Description: is UserPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isUserPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsUserPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isIAPPluginExist
- * @Description: is IAPPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isIAPPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsIAPPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isAdsPluginExist
- * @Description: is AdsPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isAdsPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsAdsPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isAnalyticsPluginExist
- * @Description: is AnalyticsPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isAnalyticsPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsAnalyticsPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isPushPluginExist
- * @Description: is PushPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isPushPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsPushPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isSharePluginExist
- * @Description: is SharePlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isSharePluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsSharePluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isSocialPluginExist
- * @Description: is SocialPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isSocialPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsSocialPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isCustomPluginExist
- * @Description: is CustomPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isCustomPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsCustomPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isRECPluginExist
- * @Description: is RECPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isRECPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsRECPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isCrashPluginExist
- * @Description: is CrashPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isCrashPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsCrashPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: isAdTrackingPluginExist
- * @Description: is AdTrackingPlugin Exist
- * @param @return true or false
- * @return boolean
- */
- public bool isAdTrackingPluginExist()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsAdTrackingPluginExist ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- /**
- *
- * @Title: setIsAnaylticsEnabled
- * @Description: choose to open or close
- * @param @param enabled true or false
- * @return void
- */
- public void setIsAnaylticsEnabled(bool enabled)
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- AnySDK_nativeSetIsAnaylticsEnabled (enabled);
- #else
- Debug.Log("This platform does not support!");
- #endif
- }
- /**
- *
- * @Title: isAnaylticsEnabled
- * @Description: the status of Anayltics
- * @param @return true or false
- * @return boolean
- */
- public bool isAnaylticsEnabled()
- {
- #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS)
- return AnySDK_nativeIsAnaylticsEnabled ();
- #else
- Debug.Log("This platform does not support!");
- return false;
- #endif
- }
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeInitPluginSystem(string appKey, string appSecret, string privateKey, string authLoginServer);
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeLoadPlugins();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeGetChannelId(StringBuilder channelId);
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeGetFrameworkVersion(StringBuilder version);
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeGetCustomParam(StringBuilder customParam);
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeRelease();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsUserPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsIAPPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsAdsPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsAnalyticsPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsSharePluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsSocialPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsPushPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsAdTrackingPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsCustomPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsRECPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsCrashPluginExist();
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern void AnySDK_nativeSetIsAnaylticsEnabled(bool enabled);
-
- [DllImport(AnySDKUtil.ANYSDK_PLATFORM)]
- private static extern bool AnySDK_nativeIsAnaylticsEnabled();
- }
- }
|