2014-04-01 239 views
0

我想按照這個tutorial,但我得到這個錯誤:無法連接到iTunes Store的錯誤代碼0

Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo=0x15c02260 {NSLocalizedDescription=Cannot connect to iTunes Store} 

我已經創造了在iTunes Connect測試用戶,但彈出連接給新用戶甚至不顯示。我已嘗試重置模擬器,從模擬器中刪除應用程序,從應用程序支持文件中刪除文件以及其他有關此錯誤的主題中提供的其他解決方案。

我最後的假設是我的代碼在某些方面是錯誤的,我沒有看到。

這是我的代碼:

-(id)init 
{ 

if (self = [super init]) { 

NSLog(@"game store loaded"); 


if ([SKPaymentQueue canMakePayments]) 
{ 
NSLog(@"can make payments"); 
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:@"teste2"]]; 
productsRequest.delegate = self; 
[productsRequest start]; 

//start Buying/buy button 
//SKProduct *selectedProduct = @"teste2"; 
//SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct]; 
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.rundogrun.prod001"]; 
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; 
[[SKPaymentQueue defaultQueue] addPayment:payment]; 

} 
else { 
NSLog(@"Please enable In App Purchase in Settings"); 
} 





} 



return self; 

} 


-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response { 
SKProduct *validProduct = nil; 
int count = [response.products count]; 
if (count > 0) { 
NSLog(@"%d products available", count); 
validProduct = [response.products objectAtIndex:0]; 
} else if (!validProduct) { 
NSLog(@"No products available"); 
} 

} 

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { 
for (SKPaymentTransaction *transaction in transactions) { 
switch (transaction.transactionState) { 
case SKPaymentTransactionStatePurchasing: 
NSLog(@"purchasing"); 
//avisa usuario que o produto esta sendo comprado 
break; 
case SKPaymentTransactionStatePurchased: 
NSLog(@"purchased"); 
//faz alguma coisa quando o produto for comprado 

[[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 
break; 
case SKPaymentTransactionStateRestored: 
NSLog(@"restored"); 
[[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 
break; 
case SKPaymentTransactionStateFailed: 
NSLog(@"failed"); 
if (transaction.error.code != SKErrorPaymentCancelled) { 
NSLog(@"An Error Encoutered %@", transaction.error.description); 
} 
[[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 

default: 
break; 
} 

} 

} 
+0

您使用的是哪個版本的iOS? IAP在iOS7的模擬器上不起作用。 –

+0

是的,我看到了這個。謝謝你的回答1 –

回答

0

在iOS系統7,IAP不模擬器工作。我在設備上運行,它工作完美!

相關問題