привет, я реализовал storeKit в своем приложении для ios, это код:
-(IBAction)Purchase:(id)sender{
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"month"];
[[SKPaymentQueue defaultQueue]addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]addPayment:payment];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
SKProduct *VailProduct = nil;
int count = [response.products count];
if (count>0) {
VailProduct = [response.products objectAtIndex:0];
} else if (!VailProduct){
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:@"No Products Are Availble!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[self EnableEmergencyCenter];
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:[NSString stringWithFormat:@"%@",transaction.error] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
}
}
это приходит на viewDidLoad:
if ([SKPaymentQueue canMakePayments])
{
// Display a store to the user.
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:@"Device Can Make Payments!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
SKProductsRequest *ProductRequst = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"month"]];
ProductRequst.delegate = self;
[ProductRequst start];
}
else {
// Warn the user that purchases are disabled.
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:@"Device Can't Make Payments!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
идентификатор продукта точен, но я продолжаю получать эту ошибку, вызванную оператором switch
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:[NSString stringWithFormat:@"%@",transaction.error] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
помогите пожалуйста:)