1
我使用下面的代碼:iOS 6的應用程式內購買SKPaymentTransaction沒有作用的方法
但錯誤是:開關箱是在保護範圍上的情況下SKPaymentTransactionStateRestored: 也 情況下SKPaymentTransactionStateFailed: 和
默認:
有人解決這個問題嗎?
先謝謝您。
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchasing:
//[self completeTransaction:transaction];
// show wait view here
statusLabel.text = @"Processing...";
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// remove wait view and unlock feature 2
statusLabel.text = @"Done!";
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:@"Complete"
message:@"You have unlocked Feature 2!"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Ok", nil];
[tmp show];
NSError *error = nil;
[SFHFKeychainUtils storeUsername:@"IAPNoob01" andPassword:@"whatever" forServiceName:kStoredData updateExisting:YES error:&error];
// apply purchase action - hide lock overlay and
[feature2Btn setBackgroundImage:nil forState:UIControlStateNormal];
// do other thing to enable the features
break;
case SKPaymentTransactionStateRestored: //ERROR:- Switch case is in protected scope
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// remove wait view here
statusLabel.text = @"";
break;
case SKPaymentTransactionStateFailed: //ERROR:- Switch case is in protected scope
if (transaction.error.code != SKErrorPaymentCancelled)
// [self failedTransaction:transaction];
{
NSLog(@"Error payment cancelled");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// remove wait view here
statusLabel.text = @"Purchase Error!";
break;
default: //ERROR:- Switch case is in protected scope
break;
}
}
}
我使用這一點,但沒有工作... – 2013-03-19 06:53:58
其工作謝謝 – 2013-03-19 07:02:16