InApp purchase on iOS 5 vs iOS 6

2019-05-20 23:05发布

问题:

I've been testing the new version of my app, which will include an in-app purchase in the next update, for one month.

Everything worked fine both on iOS 6 and 5, but recently I'm starting to get an empty SKProducts array back from the requests I make from iOS 5.

The strange thing is that, by executing the same application on iOS 6, I get the correct products array with all the elements I've set up in iTunes connect.

Anyone having the same problem? What can it be?

回答1:

You used Jail Break device to test, didnt u? You can add this to productsRequest method to check the invalid identifier

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSLog(@"Loaded list of products...");
    _productsRequest = nil;

    NSArray * skProducts = response.products;
    NSLog(@"Number of products: %d", [skProducts count]);
    for (SKProduct * skProduct in skProducts) {
        NSLog(@"Found product: %@ %@ %0.2f",
              skProduct.productIdentifier,
              skProduct.localizedTitle,
              skProduct.price.floatValue);
    }
    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }

    _completionHandler(YES, skProducts);
    _completionHandler = nil;


}

Follow this post http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/