2011-12-19 141 views
0

目前我正在致力於應用內購買功能,並且我得到的錯誤號爲錯誤域= SKErrorDomain代碼= 3「無法連接到iTunes Store」UserInfo = 0x1aaf40 {NSLocalizedDescription =無法連接到iTunes Store}

「錯誤域= SKErrorDomain代碼= 3 」無法連接到iTunes商店「 的UserInfo = {0x1aaf40 = NSLocalizedDescription無法連接到iTunes商店}」

下面是步驟。

1)首先我已創建一個應用 「inAppPro」,它是下(狀態):「準備要上傳」

enter image description here

2)我已經加入4非消費產品。並填寫相關細節。

enter image description here enter image description here

3)我曾經也爲應用程序內購買的產品測試創建測試用戶(沙盒)。

4)我還創建了配置文件,並啓用了inApp購買。

5)我也創建了沒有(*)通配符的APP ID。

這是我目前使用的代碼。

- (void)viewDidLoad 
{ 
    Detail1 *observer = [[Detail1 alloc] init]; 

    [[SKPaymentQueue defaultQueue] addTransactionObserver:observer]; 

    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; 

    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
} 


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

    if ([SKPaymentQueue canMakePayments]) 
    { 
     NSString *product = [NSString stringWithFormat:@"com.companyname.inAppDemo.module%d",ApplicationDelegate.objectID]; 
     NSLog(@"In-App product for request = %@", product); 

     SKPayment *payment = [SKPayment paymentWithProductIdentifier:product]; 
     [[SKPaymentQueue defaultQueue] addPayment:payment]; 


    } 
    else 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"You are not authorized to purchase from AppStore" 
                 delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     [alert show]; 
     [alert release]; 
    } 
} 
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions 
{ 
    for (SKPaymentTransaction *transaction in transactions) 
    { 
     switch (transaction.transactionState) 
     { 
      case SKPaymentTransactionStatePurchased: 

       [self completeTransaction:transaction]; 

       break; 

      case SKPaymentTransactionStateFailed: 

       [self failedTransaction:transaction]; 

       break; 

      case SKPaymentTransactionStateRestored: 

       [self restoreTransaction:transaction]; 

      default: 

       break; 
     }   
    } 
} 
- (void) failedTransaction: (SKPaymentTransaction *)transaction 
{ 
    if (transaction.error.code != SKErrorPaymentCancelled)  
    {  
     // Optionally, display an error here. 
     NSLog(@"%@",transaction.error); 

    } 
    [[SKPaymentQueue defaultQueue] finishTransaction: transaction]; 
} 

- (void) completeTransaction: (SKPaymentTransaction *)transaction 
{  
    //[[MKStoreManager sharedManager] provideContent: transaction.payment.productIdentifier]; 
    [[SKPaymentQueue defaultQueue] finishTransaction: transaction]; 
} 

- (void) restoreTransaction: (SKPaymentTransaction *)transaction 
{ 
    //[[MKStoreManager sharedManager] provideContent: transaction.originalTransaction.payment.productIdentifier]; 
    [[SKPaymentQueue defaultQueue] finishTransaction: transaction]; 
} 
-(IBAction)btnpurchase:(id)sender 
{ 
    NSLog(@"ProductStatus = %@", ApplicationDelegate.productStatus); 

    if ([ApplicationDelegate.productStatus isEqualToString:@"FREE"]) 
    { 
     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"This is free for you so ENJOY it!!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil]; 
     [alert show]; 
     [alert release]; 
    } 
    else if ([ApplicationDelegate.productStatus isEqualToString:@"PAID"]) 
    { 
     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"You have already purchase it!!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil]; 
     [alert show]; 
     [alert release]; 
    } 
    else 
    { 
     NSLog(@"Detail1 id for product = %d", ApplicationDelegate.objectID); 
     NSString *product = [NSString stringWithFormat:@"com.companyname.inAppDemo.module%d",ApplicationDelegate.objectID]; 
     NSLog(@"In-App product-id = %@", product); 



     SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObjects:product,nil]]; 
     request.delegate = self; 
     [request start]; 

    } 
} 

請大家幫幫我。

在此先感謝。

回答

2

您必須在「合同,稅收和銀行業務」部分有效的有效合同。 當然,請確保您使用正確的Provisioning Profile,並且您已在App Purchase中爲該ID啓用了該功能,並且(最後一項)您已在iTunes Connect中添加了可購買的項目(您的界面顯示爲您所做的)。

相關問題