From d17c98ecff2a1b7320ba313f57475d27e26169b3 Mon Sep 17 00:00:00 2001 From: Markus Stefanko Date: Thu, 8 Sep 2016 20:12:39 +0700 Subject: [PATCH] Handle empty Product Data case with event Currently when the product Data is empty, no callback will be called on haxe's side. This isn't good for cases when e.g. a promise is waiting to be fulfilled. Now this can be handled by listening for PURCHASE_PRODUCT_DATA_EMPTY --- extension/iap/IAPEvent.hx | 1 + extension/iap/ios/IAP.hx | 4 ++++ project/iphone/InAppPurchase.mm | 1 + 3 files changed, 6 insertions(+) diff --git a/extension/iap/IAPEvent.hx b/extension/iap/IAPEvent.hx index 7a7ce49..e76c15c 100644 --- a/extension/iap/IAPEvent.hx +++ b/extension/iap/IAPEvent.hx @@ -19,6 +19,7 @@ class IAPEvent extends Event { public static inline var PURCHASE_CONSUME_FAILURE = "consumeFailed"; public static inline var PURCHASE_PRODUCT_DATA_COMPLETE = "productDataComplete"; public static inline var PURCHASE_PRODUCT_DATA_FAILED = "productDataFailed"; + public static inline var PURCHASE_PRODUCT_DATA_EMPTY = "productDataEmpty"; public static inline var PURCHASE_QUERY_INVENTORY_COMPLETE = "queryInventoryComplete"; public static inline var PURCHASE_QUERY_INVENTORY_FAILED = "queryInventoryFailed"; public static inline var DOWNLOAD_COMPLETE = "downloadComplete"; diff --git a/extension/iap/ios/IAP.hx b/extension/iap/ios/IAP.hx index a59a419..1cb3cf0 100644 --- a/extension/iap/ios/IAP.hx +++ b/extension/iap/ios/IAP.hx @@ -291,6 +291,10 @@ import haxe.Json; dispatchEvent (new IAPEvent (IAPEvent.PURCHASE_PRODUCT_DATA_FAILED, data)); + case "productDataEmpty": + + dispatchEvent (new IAPEvent (IAPEvent.PURCHASE_PRODUCT_DATA_EMPTY, data)); + default: } diff --git a/project/iphone/InAppPurchase.mm b/project/iphone/InAppPurchase.mm index 17da322..dbd5723 100755 --- a/project/iphone/InAppPurchase.mm +++ b/project/iphone/InAppPurchase.mm @@ -158,6 +158,7 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu else { NSLog(@"No products are available"); + sendPurchaseEvent("productDataEmpty", nil); } }