iOS 7中不推荐使用针对应用内购买的transactionReceipt。有什么可以替换它? [英] transactionReceipt for in-app purchase is deprecated in iOS 7. What can I replace it with?

查看:902
本文介绍了iOS 7中不推荐使用针对应用内购买的transactionReceipt。有什么可以替换它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 7中,在



这是未经测试的代码,但在我的头顶,我会说一些沿着行:

  [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] 

应该得到与transactionReceipt用来返回相同的结果。


In iOS 7, on the SKPaymentTransaction class, the property transactionReceipt:

// Only valid if state is SKPaymentTransactionStatePurchased.

 @property(nonatomic, readonly) NSData *transactionReceipt

…is deprecated. But, in my code, I created a InAppPurchase class, and in my method for controlling how is the method buying, I'm using the delegate method in my code and it's like:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {

for (SKPaymentTransaction *transaction in transactions) {

    switch (transaction.transactionState) {

        case SKPaymentTransactionStatePurchasing:

                       // code and bla bla bla    
                          [self initPurchase];  
                          NSLog(@"PASO 1");          

            break;

        case SKPaymentTransactionStatePurchased:

                      // this is successfully purchased!
                            purchased = TRUE;
                            NSLog(@"PASO 2");
                           [self isPurchased];

                 NSLog(@"purchased %s", purchased? "true" : "false");

                     //  and return the transaction data

  if ([delegate respondsToSelector:@selector(successfulPurchase:restored:identifier:receipt:)])
  [delegate successfulPurchase:self restored:NO identifier:transaction.payment.productIdentifier receipt:transaction.transactionReceipt];

                     // and more code bla bla bla 

            break;

        case SKPaymentTransactionStateRestored:

                    // and more code bla bla bla 

                          [self restorePurchase];
                          NSLog(@"PASO 3");

            break;

        case SKPaymentTransactionStateFailed:

                    // and more code bla bla bla 

                           [self failedNotification];
                           NSLog(@"PASO 4");

            break;

                    //------------------------------------------//
                    //               THANKS GUYS                //
                    //          GRETTINGS FROM BOLIVIA          //
                    //             ROCK ON!!!! n_n'             //
                    //------------------------------------------//

    }
   }
  }

解决方案

You can get the receipt as the contents of the mainBundle's appStoreReceiptURL. You can find references: developer.apple.com

This is untested code, but off the top of my head, I'd say something along the lines of:

[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]]

should get you the same result that transactionReceipt used to return.

这篇关于iOS 7中不推荐使用针对应用内购买的transactionReceipt。有什么可以替换它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆