2013-07-09 16 views
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"); 
      }  

     } 
    } 
+0

沒有調用任何委託方法?你調試了嗎? – Wain

+0

您是否嘗試過在真實設備上進行測試? –

+0

我打電話給所有委託方法我只發佈兩個因爲我沒有得到response.And我在真正的設備測試 –

回答

2

這個問題仍然是存在的。這是蘋果開發者論壇上許多討論的主題,請參閱: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在設備上工作,所以您可以暫時在那裏測試。

相關問題