错误域= SKErrorDomain代码= 3“无法连接到iTunes Store”UserInfo = 0x1aaf40 {NSLocalizedDescription =无法连接到iTunes Store}

问题描述:

目前我正在致力于应用内购买功能,并且我得到的错误号为错误域= 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 hereenter 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]; 

    } 
} 

请大家帮帮我。

在此先感谢。

您必须在“合同,税收和银行业务”部分有效的有效合同。 当然,请确保您使用正确的Provisioning Profile,并且您已在App Purchase中为该ID启用了该功能,并且(最后一项)您已在iTunes Connect中添加了可购买的项目(您的界面显示为您所做的)。