要验证应用内购买产品,请执行以下操作:
- (void) validateProductIdentifiers:(NSArray *)productIdentifiers
{
if (! self.productsRequest) {
self.productsRequest = [[SKProductsRequest alloc]
initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]];
}
else {
[self.productsRequest cancel];
self.productsRequest = nil;
self.productsRequest = [[SKProductsRequest alloc]
initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]];
}
self.productsRequest.delegate = self;
[self.productsRequest start];
}
在模拟器的iOS 8.2和8.4中,start方法调用触发没有问题。
- (void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response
{
self.products = response.products;
// Remove invalid identifiers
for (NSString *invalidIdentifier in response.invalidProductIdentifiers) {
[self removeInvalidBookWithId:invalidIdentifier];
}
[self.delegate listProducts];
}
在模拟器中在iOS 7.1上运行时,回叫遇到iTunes连接错误。错误:“无法连接到iTunes Store”
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {}
我知道我无法从模拟器购买但似乎如果我至少可以看到iOS 8.2和8.4中的产品我应该可以在iOS 7.1上这样做 我真的需要7.1设备来测试它吗?