From e76bd73c6f9a0d948d80f4035db7e7a5c5563227 Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Fri, 5 Aug 2016 14:58:06 -0600 Subject: [PATCH 1/2] Add link to helpful StackOverflow answer and indicated that not everything needs to be done on a real device. --- Readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index a3d2f67..394329c 100644 --- a/Readme.md +++ b/Readme.md @@ -52,6 +52,8 @@ InAppUtils.loadProducts(products, (error, products) => { | description | string | Description string | | title | string | Title string | +**Troubleshooting:** If you do not get back your product(s) then there's a good chance that something in your iTunes Connect or Xcode is not properly configured. Take a look at this [StackOverflow Answer](http://stackoverflow.com/a/11707704/293280) to determine what might be the issue(s). + ### Buy product ```javascript @@ -115,7 +117,7 @@ InAppUtils.receiptData((error, receiptData)=> { ## Testing -To test your in-app purchases, you have to *run the app on an actual device*. Using the iOS Simulator, they will always fail. +To test your in-app purchases, you have to *run the app on an actual device*. Using the iOS Simulator, they will always fail as the simulator cannot connect to the iTunes Store. However, you can do certain tasks like using `loadProducts` without the need to run on a real device. 1. Set up a test account ("Sandbox Tester") in iTunes Connect. See the official documentation [here](https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SettingUpUserAccounts.html#//apple_ref/doc/uid/TP40011225-CH25-SW9). From 898f8a52ebd4e2e84056521c1ee4ead2c41c9fb6 Mon Sep 17 00:00:00 2001 From: Tarkus Liu Date: Thu, 6 Oct 2016 21:59:55 +0800 Subject: [PATCH 2/2] declare productsRequest as a class level variable to make it work with tvOS --- InAppUtils/InAppUtils.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/InAppUtils/InAppUtils.m b/InAppUtils/InAppUtils.m index a463173..af90e07 100644 --- a/InAppUtils/InAppUtils.m +++ b/InAppUtils/InAppUtils.m @@ -8,6 +8,7 @@ @implementation InAppUtils { NSArray *products; NSMutableDictionary *_callbacks; + SKProductsRequest *request; } - (instancetype)init @@ -144,11 +145,10 @@ - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue callback:(RCTResponseSenderBlock)callback) { if([SKPaymentQueue canMakePayments]){ - SKProductsRequest *productsRequest = [[SKProductsRequest alloc] - initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]]; - productsRequest.delegate = self; - _callbacks[RCTKeyForInstance(productsRequest)] = callback; - [productsRequest start]; + request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]]; + request.delegate = self; + _callbacks[RCTKeyForInstance(request)] = callback; + [request start]; } else { callback(@[@"not_available"]); }