1

我已经为我的应用实施了应用内购买。它工作正常,但现在我无法在之后得到回复SKProductsRequest

附加我的代码

[self.delegate showProgressHUDWithTitle:@"Loading Product"];
// select from IPA Items //

// Check if Parental Control is enabled so that purchase will fail //
if ([SKPaymentQueue canMakePayments])
{
 SKProductsRequest *Prequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"Item 1"]];

  Prequest.delegate = self;
  [Prequest start];
  request = Prequest;

}

这个方法也没有被调用---> -(void)request:(SKRequest *)request didFailWithError:(NSError *) error

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

    [self.delegate hideProgressHUD];

    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];

    SKProduct *validProduct = nil;

    int count = [response.products count];

    if (count>0)
    {
             validProduct = [response.products objectAtIndex:0];
            if ([validProduct.productIdentifier isEqualToString:purchasingItem])
            {
                SKPayment *payment = [SKPayment paymentWithProduct:validProduct];
                [[SKPaymentQueue defaultQueue] addPayment:payment];
            }
            else
            {
                NSLog(@"No Valid Products");
            }    

      }
  } 
4

1 回答 1

2

这个问题仍在发生。它是 Apple Developer Forums 上许多讨论的主题,请参阅:SKProductsRequest does not work。我添加了线程建议的以下代码以验证我是否遇到了同样的问题,我建议您也这样做。

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"In-App Store unavailable" message:@"The In-App Store is currently unavailable, please try again later." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

}

我不打算将此代码投入生产,如果发生这种情况,我将禁用应用内购买按钮,然后再检查。

这似乎是过去几周 Xcode 5 模拟器的问题。我不知道在哪里查看修复状态。IAP 在设备上运行,因此您可以暂时在那里进行测试。

于 2013-09-21T19:39:38.323 回答