これはコードです:
-(IBAction)purchase5010:(id)sender{
productUserRequests = 0;
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.mobice.wtm.5010"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:productUserRequests];
}else if(!validProduct){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No products available at this time."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:productUserRequests];
}else if(!validProduct){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No products available at this time."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
if (productUserRequests == 0) {
NSString *hints = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:@"Hints"]];
int hintValue = [hints intValue];
hintValue+=50;
[hints release];
hints = [[NSString alloc]initWithFormat:@"%i", hintValue];
[hints writeToFile:[self pathOfFile:@"Hints"] atomically:YES];
NSString *reveals = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:@"Reveals"]];
int revealValue = [reveals intValue];
revealValue+=50;
[reveals release];
reveals = [[NSString alloc]initWithFormat:@"%i", revealValue];
[reveals writeToFile:[self pathOfFile:@"Reveals"] atomically:YES];
}else if(productUserRequests == 1){
NSString *hints = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:@"Hints"]];
int hintValue = [hints intValue];
hintValue+=150;
[hints release];
hints = [[NSString alloc]initWithFormat:@"%i", hintValue];
[hints writeToFile:[self pathOfFile:@"Hints"] atomically:YES];
NSString *reveals = [[NSString alloc]initWithContentsOfFile:[self pathOfFile:@"Reveals"]];
int revealValue = [reveals intValue];
revealValue+=20;
[reveals release];
reveals = [[NSString alloc]initWithFormat:@"%i", revealValue];
[reveals writeToFile:[self pathOfFile:@"Reveals"] atomically:YES];
}
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"In-app purchase failed. No money was charged."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
}
}
今、アイテムを購入しようとすると、「現在、利用できる製品はありません。」と表示され、「アプリ内購入に失敗しました。お金は請求されませんでした。」と表示されます。知りたいのですが、上記のコードに何か問題がありますか? それとも、iTunes 接続の問題である可能性が高いですか?