TapTapAPI.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using UnityEngine;
  3. namespace TapIabHelper
  4. {
  5. public class TapTapAPI
  6. {
  7. private static AndroidJavaClass getAgent()
  8. {
  9. if (TapTapAPI.agent == null)
  10. {
  11. TapTapAPI.agent = new AndroidJavaClass(TapTapAPI.JAVA_CLASS);
  12. }
  13. return TapTapAPI.agent;
  14. }
  15. private static AndroidJavaClass getUnityClass()
  16. {
  17. if (TapTapAPI.unityClass == null)
  18. {
  19. TapTapAPI.unityClass = new AndroidJavaClass(TapTapAPI.UNITY_CLASS);
  20. }
  21. return TapTapAPI.unityClass;
  22. }
  23. public static void OnStart(TapTapAPI.Callback licenseCallback)
  24. {
  25. //TapTapAPI._licenseCallback = licenseCallback;
  26. //AndroidJavaObject @static = TapTapAPI.getUnityClass().GetStatic<AndroidJavaObject>("currentActivity");
  27. //TapTapAPI.getAgent().CallStatic("init", new object[]
  28. //{
  29. // @static,
  30. // string.Empty,
  31. // new TapTapAPI.TapTapSDKListener()
  32. //});
  33. }
  34. public static void OnDestroy()
  35. {
  36. //TapTapAPI.getAgent().CallStatic("destroy", new object[0]);
  37. }
  38. public static void DownloadTapTap()
  39. {
  40. //TapTapAPI.getAgent().CallStatic("downloadTapTap", new object[0]);
  41. }
  42. public static void OpenTapTap()
  43. {
  44. //TapTapAPI.getAgent().CallStatic("openTapTap", new object[0]);
  45. }
  46. public const string PUBLIC_KEY = "";
  47. public static string JAVA_CLASS = "com.unity3d.player.UnityPlayer";
  48. public static string JAVA_INTERFACE = "com.unity3d.player.UnityPlayer";
  49. private static string UNITY_CLASS = "com.unity3d.player.UnityPlayer";
  50. private static AndroidJavaClass agent;
  51. private static AndroidJavaClass unityClass;
  52. public const int LICENSE_OK = 0;
  53. public const int LICENSE_NOT_INSTALL_TAPTAP = 1;
  54. public const int LICENSE_NO = 2;
  55. public const int LICENSE_NOT_SERVICE_UNAVAILABLE = 3;
  56. public const int BILLING_RESULT_OK = 0;
  57. public const int BILLING_RESULT_NOT_INSTALL_TAPTAP = 1;
  58. public const int BILLING_RESULT_ERR = 2;
  59. private static TapTapAPI.Callback _licenseCallback;
  60. public delegate void Callback(int code);
  61. public class TapTapSDKListener : AndroidJavaProxy
  62. {
  63. public TapTapSDKListener() : base(TapTapAPI.JAVA_INTERFACE)
  64. {
  65. }
  66. public void onLicenseCallback(int code)
  67. {
  68. if (TapTapAPI._licenseCallback != null)
  69. {
  70. TapTapAPI._licenseCallback(code);
  71. }
  72. }
  73. }
  74. }
  75. }