【问题标题】:ios 6 InApp Purchase SKPaymentTransaction dose not work methodios 6 In App Purchase SKPaymentTransaction 不起作用的方法
【发布时间】:2013-03-19 06:41:10
【问题描述】:

我正在使用以下代码:

但错误是:切换案例在案例 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;
        }
    }
}

【问题讨论】:

    标签: ios6 in-app-purchase in-app-billing storekit xcode4.6


    【解决方案1】:

    您应该用{} 括起来。

    例子:

        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchasing:
                {
                    //[self completeTransaction:transaction];
                    // show wait view here
                    statusLabel.text = @"Processing...";
                    break;
                }
            case SKPaymentTransactionStateFailed:
                {
                    // another case contents
                    break;
                }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-29
      • 1970-01-01
      • 2016-11-23
      • 2016-03-15
      • 2021-02-15
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      相关资源
      最近更新 更多