2014-02-14 34 views
0

在iPhone 5上都是好的,但在iPhone 3,4我得到交易失敗的狀態後按購買的按鈕... 我已嘗試幾乎所有東西,但始終同樣的問題,如果你有同樣的問題,你知道答案,請幫助它不到一分鐘;)謝謝!在應用程序購買不工作在iPhone 3,4

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { 
    for (SKPaymentTransaction *transaction in transactions) { 
     switch (transaction.transactionState) { 
      case SKPaymentTransactionStatePurchasing:{ 
       // show wait view here 
       NSLog(@"Processing..."); 
       break; 
      } 
      case SKPaymentTransactionStatePurchased:{ 
       [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 
       // remove wait view and unlock feature 2 
       NSLog(@"DONE!"); 

       [prefs setObject:@"yes" forKey:@"payed"]; 
       self.buyButton.hidden = TRUE; 
       [self getData:@"yes"]; 
       break; 
      } 
      case SKPaymentTransactionStateRestored:{ 
       [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 
       NSLog(@"Error payment cancelled2"); 
       break; 
      } 
      case SKPaymentTransactionStateFailed:{ 
       if (transaction.error.code != SKErrorPaymentCancelled) { 
        NSLog(@"Error payment cancelled1:%@",transaction.error.description); 
       } 
       [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 
       break; 
      } 
      default:{ 
       break; 
      } 
     } 
    } 
} 






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

    // remove wait view here 
    //statusLabel.text = @""; 

    int count = [response.products count]; 

    if (count>0) { 
     SKProduct *validProduct = [response.products objectAtIndex:0]; 

     //SKPayment *payment = [SKPayment paymentWithProduct:validProduct]; 
     [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; 
     SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:validProduct]; 

     [[SKPaymentQueue defaultQueue] addPayment:payment]; 

    } else { 
     // no products found 
    } 


} 

-(void)requestDidFinish:(SKRequest *)request 
{ 

} 

-(void)request:(SKRequest *)request didFailWithError:(NSError *)error 
{ 
    NSLog(@"Failed to connect with error: %@", [error localizedDescription]); 
} 



#pragma mark AlertView Delegate 
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

    NSLog(@"%d",buttonIndex); 

    if (alertView==askToPurchase) { 
     if (buttonIndex==1) { 
      // user tapped YES, but we need to check if IAP is enabled or not. 
      if ([SKPaymentQueue canMakePayments]) { 

       SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.adam.CrowdControl.adamProduct1"]]; 

       request.delegate = self; 
       [request start]; 


      } else { 
       UIAlertView *tmp = [[UIAlertView alloc] 
            initWithTitle:@"Prohibited" 
            message:@"Parental Control is enabled, cannot make a purchase!" 
            delegate:self 
            cancelButtonTitle:nil 
            otherButtonTitles:@"Ok", nil]; 
       [tmp show]; 
      } 
     } 
    } 

} 

回答

1

我不認爲這與手機型號有關。

沙盒模式的應用程序?如果是這樣,手機上一定不能保存任何iTunes賬號。在每部手機上從您的帳戶註銷。您只能使用您在iTunes Connect中創建的「測試用戶」帳戶成功進行測試。

我假設你在iTunes Connect中做了關於IAP的所有安排,增加了產品vs.因爲你說它在一個電話上工作。

-1

您是否向蘋果提交了您的應用程序版本?你需要提交它,選擇你的應用商店內容,然後拒絕它(因爲還不是最終版本)。 此外,允許一段時間後(12小時左右,因爲我看到有時會有很長的延遲)。 還有一件事,使用美國測試帳戶和提交給美國商店的項目(我記得其他任何失敗的項目)。