本文介绍了SKReceiptRequest不调用(符合NSBundle)SKRequestDelegate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在按照Apple的收据验证编程指南执行本地收据验证。我在 NSBundle 上定义了一个符合 SKRequestDelegate 的类别,它提供了一种收据验证方法,我从在 main()内部,然后初始化应用程序委托并将其传递给 UIApplicationMain()。这就是文档所说的:

I am currently implementing local receipt validation following Apple's Receipt Validation Programming Guide. I have defined a category on NSBundle that conforms to SKRequestDelegate and that offers a method for receipt validation, which I call from inside main() before it initializes the application delegate and passes it to UIApplicationMain(). This is what the documentation says:

当没有收据在 self.appStoreReceiptURL ,我的收据验证方法准备一个 SKReceiptRequest ,其属性如下,并将自己设置为委托。由于它符合 SQRequestDelegate ,它实现了 requestDidFinish: request:didFailWithError:

When there is no receipt at self.appStoreReceiptURL, my method for receipt validation prepares an SKReceiptRequest with properties as follows and sets itself as delegate. Since it conforms to SQRequestDelegate it implements both requestDidFinish: and request:didFailWithError:.

NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
                            @NO, SKReceiptPropertyIsExpired,
                            @NO, SKReceiptPropertyIsRevoked,
                            @NO, SKReceiptPropertyIsVolumePurchase,
                            nil];

奇怪的是,在应用程序类别启动请求后,这两种方法都没有被调用正在Xcode调试器中运行。有什么可以解释这个?如何在开发期间收到(刷新)收据,最好是 NSBundle 上的类别?是否应该尽早在申请代表成立之前发送请求(尽管所引用的文件表明了什么)?有没有我可以参考的工作示例代码?

The odd thing is that neither of the two methods is called after the category starts the request while the app is running in the Xcode debugger. What could explain this? How can I receive (refresh) a receipt during development preferably with a category on NSBundle? Is it perhaps to early to send the request before the application delegate has come into existence (despite of what the cited documentation indicates)? Is there any working sample code that I could consult?

推荐答案

看起来好像有几个原因导致这个失败,使用该类别(此时)是其中之一。如果我进行了以下更改,我会收到回复 requestDidFinish:并可以取得进展:

It looks as if there were several reasons why this failed, the use of the category (at this time) being one of them. If I make the following changes I receive callbacks to requestDidFinish: and can make progress:


  • 在物理设备而不是模拟器上的调试器中启动应用程序。 StoreKit(和应用程序内购买)将无法在模拟器中运行。这在。)

  • Launch the app in the debugger on a physical device, not the simulator. Apparently StoreKit (and in-app purchaseses) will not work in the simulator. This is documented in Xcode 5.1.1 release notes.)

让对象类别(不是类别本身)符合 SKRequestDelegate 。 (我想了解为什么这是一个明显的要求,但目前没有。)

Let a object owned by the category (not the category itself) conform to SKRequestDelegate. (I would like to understand why this is an apparent requirement, but currently do not.)

SKReceiptRefreshRequest 及其 SKRequestDelegate 在整个请求期间。保留任何一个但不保留另一个显然是不够的。 (请注意, SKRequest 没有维护。)

Retain both the SKReceiptRefreshRequest and its SKRequestDelegate during the entire duration of the request. Retaining either one but not the other is apparently insufficient. (Notice that SKRequest does not maintain a strong link to the delegate.)

这篇关于SKReceiptRequest不调用(符合NSBundle)SKRequestDelegate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 11:47