Skip to content

Commit d213050

Browse files
committed
-update IapManager
1 parent 11ec9f8 commit d213050

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

LICENSE.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/IapManager.cs

+8-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UnityEngine;
66
using UnityEngine.Purchasing;
77
using UnityEngine.Purchasing.Extension;
8+
89
namespace VirtueSky.Iap
910
{
1011
public class IapManager : MonoBehaviour, IDetailedStoreListener
@@ -13,6 +14,7 @@ public class IapManager : MonoBehaviour, IDetailedStoreListener
1314
public static event Action<string> OnPurchaseSucceedEvent;
1415
public static event Action<string> OnPurchaseFailedEvent;
1516
public static event Action<Product> OnIapTrackingRevenueEvent;
17+
public static event Action<bool> OnShowIapNativePopupEvent;
1618

1719
private IStoreController _controller;
1820
private IExtensionProvider _extensionProvider;
@@ -70,16 +72,6 @@ private void PurchaseProductInternal(IapDataProduct product)
7072
#endif
7173
}
7274

73-
private void PurchaseProductInternal(string id)
74-
{
75-
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
76-
_controller?.InitiatePurchase(id);
77-
#elif UNITY_EDITOR
78-
InternalPurchaseSuccess(id);
79-
#endif
80-
}
81-
82-
8375
private void RequestProductData(ConfigurationBuilder builder)
8476
{
8577
foreach (var p in iapSettings.IapDataProducts)
@@ -90,7 +82,7 @@ private void RequestProductData(ConfigurationBuilder builder)
9082

9183
private void InternalPurchaseFailed(string id)
9284
{
93-
//AdStatic.OnChangePreventDisplayAppOpenEvent?.Invoke(false);
85+
OnShowIapNativePopupEvent?.Invoke(false);
9486
foreach (var product in iapSettings.IapDataProducts)
9587
{
9688
if (product.Id != id) continue;
@@ -157,14 +149,13 @@ public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
157149

158150
void PurchaseVerified(PurchaseEventArgs purchaseEvent)
159151
{
160-
//AdStatic.OnChangePreventDisplayAppOpenEvent?.Invoke(false);
152+
OnShowIapNativePopupEvent?.Invoke(false);
161153
OnIapTrackingRevenueEvent?.Invoke(purchaseEvent.purchasedProduct);
162154
InternalPurchaseSuccess(purchaseEvent.purchasedProduct.definition.id);
163155
}
164156

165157
void InternalPurchaseSuccess(string id)
166158
{
167-
//AdStatic.OnChangePreventDisplayAppOpenEvent?.Invoke(false);
168159
foreach (var product in iapSettings.IapDataProducts)
169160
{
170161
if (product.Id != id) continue;
@@ -250,26 +241,28 @@ private static void AutoInitialize()
250241
DontDestroyOnLoad(iapManager);
251242
}
252243
}
244+
253245
private void CallActionAndClean(ref Action action)
254246
{
255247
if (action == null) return;
256248
var a = action;
257249
a();
258250
action = null;
259251
}
252+
260253
#region API
261254

262255
public IapDataProduct PurchaseProduct(string id)
263256
{
264-
//AdStatic.OnChangePreventDisplayAppOpenEvent?.Invoke(true);
257+
OnShowIapNativePopupEvent?.Invoke(true);
265258
var product = iapSettings.GetIapProduct(id);
266259
PurchaseProductInternal(product);
267260
return product;
268261
}
269262

270263
public IapDataProduct PurchaseProduct(IapDataProduct product)
271264
{
272-
//AdStatic.OnChangePreventDisplayAppOpenEvent?.Invoke(true);
265+
OnShowIapNativePopupEvent?.Invoke(true);
273266
PurchaseProductInternal(product);
274267
return product;
275268
}

0 commit comments

Comments
 (0)