+ add new iap API method for subscraption.
							parent
							
								
									ad47a9696b
								
							
						
					
					
						commit
						2cc9d66aa1
					
				|  | @ -233,12 +233,12 @@ namespace Guru | |||
|         private void CheckPermission() | ||||
|         { | ||||
|             float delay = 1; | ||||
|             Debug.Log($"---- Check PushPermission ---"); | ||||
|             UnityEngine.Debug.Log($"---- Check PushPermission ---"); | ||||
| #if UNITY_ANDROID | ||||
|             // 如果已经请求过权限的话, 则不做动作 | ||||
|             if (UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION)) | ||||
|             { | ||||
|                 Debug.Log($"--- PushPermission has passed ---"); | ||||
|                 UnityEngine.Debug.Log($"--- PushPermission has passed ---"); | ||||
|                 return; | ||||
|             } | ||||
| #endif | ||||
|  | @ -251,7 +251,7 @@ namespace Guru | |||
|         private void RequestNotification() | ||||
|         { | ||||
| #if UNITY_ANDROID | ||||
|             Debug.Log("--- Target 33 Request Notification ---"); | ||||
|             UnityEngine.Debug.Log("--- Target 33 Request Notification ---"); | ||||
|             // Android直接申请授权 | ||||
|             if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION)) | ||||
|             { | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ namespace Guru | |||
|         /// <summary> | ||||
|         /// 初始化IAP 功能 | ||||
|         /// </summary> | ||||
|         public static void InitIAP(byte[] googleKey, byte[] appleRootCerts) | ||||
|         public static void InitIAP(string userId, byte[] googleKey, byte[] appleRootCerts) | ||||
|         { | ||||
|             GuruIAP.Instance.OnInitResult += OnIAPInitResult; | ||||
|             GuruIAP.Instance.OnRestored += OnRestored; | ||||
|  | @ -34,7 +34,7 @@ namespace Guru | |||
|              | ||||
|             Callbacks.IAP._onIAPInitStart?.Invoke(); // 初始化之前进行调用 | ||||
|              | ||||
|             GuruIAP.Instance.InitWithKeys(googleKey, appleRootCerts, IsDebugMode); | ||||
|             GuruIAP.Instance.InitWithKeys(userId, googleKey, appleRootCerts, IsDebugMode); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|  | @ -245,5 +245,93 @@ namespace Guru | |||
| 
 | ||||
|         #endregion | ||||
| 
 | ||||
|         #region Subscriptions | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// 订阅是否被取消 | ||||
|         /// </summary> | ||||
|         /// <param name="productName"></param> | ||||
|         /// <returns></returns> | ||||
|         public static bool IsSubscriptionCancelled(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.IsSubscriptionCancelled(productName); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         /// 订阅是否可用 | ||||
|         /// </summary> | ||||
|         /// <param name="productName"></param> | ||||
|         /// <returns></returns> | ||||
|         public static bool IsSubscriptionAvailable(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.IsSubscriptionAvailable(productName); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         /// 订阅是否过期 | ||||
|         /// </summary> | ||||
|         /// <param name="productName"></param> | ||||
|         /// <returns></returns> | ||||
|         public static bool IsSubscriptionExpired(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.IsSubscriptionExpired(productName); | ||||
|         } | ||||
|          | ||||
|         public static bool IsSubscriptionFreeTrail(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.IsSubscriptionFreeTrail(productName); | ||||
|         } | ||||
|          | ||||
|         public static bool IsSubscriptionAutoRenewing(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.IsSubscriptionAutoRenewing(productName); | ||||
|         } | ||||
|          | ||||
|         public static bool IsSubscriptionIntroductoryPricePeriod(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.IsSubscriptionIntroductoryPricePeriod(productName); | ||||
|         } | ||||
|          | ||||
|         public DateTime GetSubscriptionExpireDate(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionExpireDate(productName); | ||||
|         } | ||||
|          | ||||
|          | ||||
|         public DateTime GetSubscriptionPurchaseDate(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionPurchaseDate(productName); | ||||
|         } | ||||
|          | ||||
|          | ||||
|         public DateTime GetSubscriptionCancelDate(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionCancelDate(productName); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         public TimeSpan GetSubscriptionRemainingTime(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionRemainingTime(productName); | ||||
|         } | ||||
|          | ||||
|         public TimeSpan GetSubscriptionIntroductoryPricePeriod(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionIntroductoryPricePeriod(productName); | ||||
|         } | ||||
|          | ||||
|          | ||||
|         public TimeSpan GetSubscriptionFreeTrialPeriod(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionFreeTrialPeriod(productName); | ||||
|         } | ||||
|          | ||||
|         public string GetSubscriptionInfoJsonString(string productName) | ||||
|         { | ||||
|             return GuruIAP.Instance.GetSubscriptionInfoJsonString(productName); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         #endregion | ||||
|     } | ||||
| } | ||||
|  | @ -334,7 +334,13 @@ namespace Guru | |||
|                 Try(() => | ||||
|                 { | ||||
|                     LogI($"#4.3 --- Start IAP ---"); | ||||
|                     InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP | ||||
|                     if (_initConfig.GoogleKeys == null || _initConfig.AppleRootCerts == null) | ||||
|                     { | ||||
|                         LogException("[IAP] GoogleKeys is null when using IAPService! Integration failed. App will Exit"); | ||||
|                     } | ||||
| 
 | ||||
| 
 | ||||
|                     InitIAP(UID, _initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP | ||||
|                 }, ex => | ||||
|                 { | ||||
|                     UnityEngine.Debug.LogError($"--- ERROR on useIAP: {ex.Message}"); | ||||
|  |  | |||
|  | @ -2,13 +2,13 @@ | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| using UnityEngine; | ||||
| 
 | ||||
| namespace Guru.Debug.Tests | ||||
| { | ||||
|     using Debug; | ||||
|     using UnityEditor; | ||||
|     using NUnit.Framework; | ||||
|     using UnityEngine; | ||||
|     using System; | ||||
|      | ||||
|     public class Test_IAP | ||||
|     { | ||||
|  | @ -18,9 +18,16 @@ namespace Guru.Debug.Tests | |||
|         { | ||||
|             var model = IAPModel.Load(); | ||||
|             int level = 1; | ||||
|             int orderType = 0; | ||||
|             for (int i = 0; i < 5; i++) | ||||
|             { | ||||
|                 model.AddAppleOrder(new AppleOrderData(0, $"i.iap.test.icon_{i}", "receipt_{i}", level)); | ||||
|                 model.AddAppleOrder(new AppleOrderData(orderType,  | ||||
|                     $"i.iap.test.icon_{i}",  | ||||
|                     $"receipt_{i}",  | ||||
|                     $"order_id_{i}",  | ||||
|                     DateTime.Now.ToString("g"),  | ||||
|                     level)); | ||||
|                  | ||||
|                 level++; | ||||
|             } | ||||
|              | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ | |||
|   "description": "Guru SDK for unity project", | ||||
|   "unity": "2020.3", | ||||
|   "author":{ | ||||
|     "name": "Guru Games" | ||||
|     "name": "Guru Game" | ||||
|   }, | ||||
|   "license": "MIT", | ||||
|   "category": "Game,Tool,Development", | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue