在IOS7验证期间创建收据

时间:2014-03-18 03:06:06

标签: ios7 in-app-purchase

我已开始在IOS7上测试应用内购买并正在进行收据验证,但我对在测试期间实际生成收据(从Xcode启动应用程序)感到困惑。根据2013 WWDC视频#508,当您从商店下载应用程序时,会生成收据。因此,当我第一次从Xcode推出我的应用并且没有找到收据时,这并不奇怪,因为商店没有参与交易。但是,我在Apple的Receipt Validation Programming Guide中找到了这个小故事:

Test During the Development Process

In order to test your main application during the development process, you need a 
valid receipt so that your application launches. To set this up, do the following:

Make sure you have Internet access so you can connect to Apple’s servers.
Launch your application by double-clicking on it (or in some way cause Launch Services 
to launch it). After you launch your application, the following occurs:

Your application fails to validate its receipt because there is no receipt present, and 
it exits with a status of 173.
The system interprets the exit status and attempts to obtain a valid receipt. Assuming 
your application signing certificate is valid, the system installs a valid receipt for the
application. The system may prompt you for your iTunes credentials.
The system relaunches your application, and your application successfully validates the
receipt.
With this development receipt installed, you can launch your application by any 
method—for  example, with gdb or the Xcode debugger.

所以我尝试了以下代码:

NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if (!receipt)
{
    NSLog(@"    No receipt found!");
    exit(173);

确实报告了“未找到收据”并退出。我从设备上重新启动了应用程序。它很快就退出了。我从Xcode重新启动,它再次退出......没有收据。

此时,我很困惑。我可能在这里遗漏了一些明显的东西,但是:在开发过程中测试时如何生成初始收据?

谢谢,

0 个答案:

没有答案