应用内购买沙箱测试是否可能不适用于 iOS,因为它还处于测试阶段?它可以在 iOS 6 模拟器和设备上运行,但不能在 iOS 7 模拟器或设备上运行,一直提示无法连接到 iTunes。
代码:
- (void)purchaseRemoveAds
{
NSLog(@"ITEMS :%@", [IAPShare sharedHelper].iap.productIdentifiers);
[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
{
if(response > 0 ) {
NSLog(@"PRODUCTS: %@", [IAPShare sharedHelper].iap.products);
if ([[IAPShare sharedHelper].iap.products count] != 0) {
SKProduct* product =[[IAPShare sharedHelper].iap.products objectAtIndex:0];
[[IAPShare sharedHelper].iap buyProduct:product
onCompletion:^(SKPaymentTransaction* trans){
if(trans.error)
{
NSLog(@"Fail %@",[trans.error localizedDescription]);
}
else if(trans.transactionState == SKPaymentTransactionStatePurchased) {
[[IAPShare sharedHelper].iap provideContent:@"RemoveAds"];
NSLog(@"SUCCESS %@",response);
NSLog(@"Purchases %@",[IAPShare sharedHelper].iap.purchasedProducts);
[bannerView_ removeFromSuperview];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success!" message:[NSString stringWithFormat:@"You have successfully purchased %@", product.localizedTitle] delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles: nil];
[alert show];
}
else if(trans.transactionState == SKPaymentTransactionStateFailed) {
NSLog(@"Fail");
}
}];//end of buy product
}
}
}];
}
最佳答案
根据苹果文档,他们不支持 iOS7 模拟器中的应用内购买。您需要使用设备来测试应用内购买。我不知道为什么也无法使用设备测试应用内购买。
请引用apple doc 。其中引用 iOS 模拟器。
关于iphone - iOS 7 Beta - 应用内测试不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18833187/