Reputation: 178
Code as following - this code worked yesterday are providing invalid ID's now longer works, i've been though code about 10 times
.m
#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>
@interface InAppViewController : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver> {
SKProduct *proUpgradeProduct;
SKProductsRequest *productsRequest;
}
.h
#import "InAppViewController.h"
@implementation InAppViewController
- (void)viewDidLoad{
[self requestProUpgradeProductData];
}
- (void)dealloc {
[super dealloc];
}
- (void)requestProUpgradeProductData
{
NSLog(@"called productsRequest");
NSSet *productIdentifiers = [NSSet setWithObject:@"com.okz8.investor.gem15" ];
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
// we will release the request object in the delegate callback
}
#pragma mark -
#pragma mark SKProductsRequestDelegate methods
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *products = response.products;
proUpgradeProduct = [products count] == 1 ? [[products firstObject] retain] : nil;
if (proUpgradeProduct)
{
NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle);
NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription);
NSLog(@"Product price: %@" , proUpgradeProduct.price);
NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier);
}
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(@"Invalid product id: %@" , invalidProductId);
}
// finally release the reqest we alloc/init’ed in requestProUpgradeProductData
[productsRequest release];
//[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}
This just does not return response i've done all here http://troybrant.net/blog/2010/01/invalid-product-ids/
Was getting invalid ID's now i dont get anything
Upvotes: 4
Views: 9637
Reputation: 8880
I just had this problem in an iOS 15 device.
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
is also implemented, and also not called.
Reboot of device and it all worked again!
When this happens I get this, or similar, in the log:
[BackgroundTask] Background Task 6 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
Upvotes: 4
Reputation: 1768
By the way, it seems, that in the case, when the set of product identifiers being passed during the construction of a SKProductsRequest
is empty, neither of the SKProductsRequestDelegate
delegate functions are called.
Upvotes: 0
Reputation: 7347
Based on user178379 response, Try to implement this method:
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
NSLog(@"request - didFailWithError: %@", [[error userInfo] objectForKey:@"NSLocalizedDescription"]);
}
My problem was: Cannot connect to iTunes Store
, which was for:
StoreKit (In-App purchases) will not work in the Simulator. 13962338
Upvotes: 6
Reputation: 248
Had the same problem and found the solution here: productsRequest response method is not calling
Due to automatic reference counting my request was immediately deleted again...
Upvotes: 6