diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index 06a88ee8..fed17512 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -133,6 +133,7 @@ @implementation RMStore { NSMutableDictionary *_addPaymentParameters; // HACK: We use a dictionary of product identifiers because the returned SKPayment is different from the one we add to the queue. Bad Apple. NSMutableDictionary *_products; NSMutableSet *_productsRequestDelegates; + NSMutableSet *_productsRequests; NSMutableArray *_restoredTransactions; @@ -154,6 +155,7 @@ - (id) init _addPaymentParameters = [NSMutableDictionary dictionary]; _products = [NSMutableDictionary dictionary]; _productsRequestDelegates = [NSMutableSet set]; + _productsRequests = [NSMutableSet set]; _restoredTransactions = [NSMutableArray array]; [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; } @@ -241,7 +243,8 @@ - (void)requestProducts:(NSSet*)identifiers SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers]; productsRequest.delegate = delegate; - + [_productsRequests addObject:productsRequest]; + [productsRequest start]; } @@ -739,6 +742,11 @@ - (void)removeProductsRequestDelegate:(RMProductsRequestDelegate*)delegate [_productsRequestDelegates removeObject:delegate]; } +- (void)removeProductsRequest:(SKProductsRequest*)productsRequest +{ + [_productsRequests removeObject:productsRequest]; +} + @end @implementation RMProductsRequestDelegate @@ -767,12 +775,13 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu [[NSNotificationCenter defaultCenter] postNotificationName:RMSKProductsRequestFinished object:self.store userInfo:userInfo]; } -- (void)requestDidFinish:(SKRequest *)request +- (void)requestDidFinish:(SKProductsRequest *)request { [self.store removeProductsRequestDelegate:self]; + [self.store removeProductsRequest:request]; } -- (void)request:(SKRequest *)request didFailWithError:(NSError *)error +- (void)request:(SKProductsRequest *)request didFailWithError:(NSError *)error { RMStoreLog(@"products request failed with error %@", error.debugDescription); if (self.failureBlock) @@ -786,6 +795,7 @@ - (void)request:(SKRequest *)request didFailWithError:(NSError *)error } [[NSNotificationCenter defaultCenter] postNotificationName:RMSKProductsRequestFailed object:self.store userInfo:userInfo]; [self.store removeProductsRequestDelegate:self]; + [self.store removeProductsRequest:request]; } @end