SKProductsRequest does not work in iOS 11 Simulators

Buying an iOS simulator is a well-known "no, it's impossible." However, obtaining SKProduct information by providing product identifiers for SKProductsRequest used to work prior to iOS 11.

In SKProductsRequestDelegate I get the following error: Error Domain=SSErrorDomain Code=0 "Cannot connect to iTunes Store" From what I found out, this can happen either with the wrong product identifier or on Apple Sandbox servers. However, this is not so, since the products load perfectly on iOS 10 ..

My product download implementation is almost the same as in the Apple manual

Does anyone else experience this or find a solution?

Products load perfectly when the application runs on a physical device. I am using Xcode 9.0.

+7
ios storekit in-app-purchase skproduct
source share
2 answers

The same thing here. If you repeat the request when it does not work, try again. After repeating it, he will finally return the products. This can take 10, 50, or even more than 100 repetitions.

So here is what my code looks like:

 - (void)inquireProducts { _availableProducts = [NSMutableArray arrayWithCapacity:0]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"productIds" withExtension:@"plist"]; knownProductIdentifiers = [NSArray arrayWithContentsOfURL:url]; if (knownProductIdentifiers && knownProductIdentifiers.count) { // Keep a strong reference to the product request productsRequest = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithArray:knownProductIdentifiers]]; productsRequest.delegate = self; [productsRequest start]; } } #pragma mark SKProductsRequestDelegate method - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { for (SKProduct *product in response.products) { [_availableProducts addObject:product]; } productsRequest = nil; [[NSNotificationCenter defaultCenter] postNotificationName:IAPPurchaseNotification object:self]; } - (void)request:(SKRequest *)request didFailWithError:(NSError *)error { if (request == productsRequest) { static int count = 0; NSLog(@"Request %@ failed on %d. attempt with error: %@", request, ++count, error); productsRequest = nil; // try again until we succeed [self inquireProducts]; } } 
+4
source share

This is a problem with the apple. I also had a similar problem. After a lot, I recall the method of requesting a product 10 times, and I received a response in a second attempt. It works only for iOS 9 and 11. Not for iOS 10. And as soon as you receive your products, you will receive it for the first time later. It works on both the device and the simulator. My implementation is similar:

 - (void)request:(SKRequest *)request didFailWithError:(NSError *)error { int tried=(int)[[NSUserDefaults standardUserDefaults] integerForKey:@"try"]; [[NSUserDefaults standardUserDefaults] setInteger:tried+1 forKey:@"try"]; [[NSUserDefaults standardUserDefaults] synchronize]; if([[GameState shared].availableInApps count]==0&&(int)[[NSUserDefaults standardUserDefaults] integerForKey:@"try"]>10) { [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(retry_product) userInfo:nil repeats:NO]; } 
0
source share

All Articles