在App Purchase中没有回复

时间:2013-07-09 07:08:19

标签: iphone ios ipad in-app-purchase

我已经为我的应用程序实施了In App Purchase。它工作正常但现在我无法在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");
            }    

      }
  } 

1 个答案:

答案 0 :(得分: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适用于设备,因此您可以暂时在那里进行测试。