2

我刚刚在我的 iTunes 中添加了一个 IAP,并添加了一个测试用户,一切看起来都很好,并且 IAP 已为我的游戏启用。在 Apple Docs 中,它说将此代码放入 AppDelegate

 // Locate the receipt
    NSString *receiptPath = [[[NSBundle mainBundle] appStoreReceiptURL] path];

    // Test whether the receipt is present at the above path
    if (![[NSFileManager defaultManager] fileExistsAtPath:receiptPath]) {

        NSLog(@"Exit");
        // Validation fails
        exit(173);
    }

我不太明白该代码的意义是什么?当我使用其中的代码运行游戏时,它会立即退出,我做错了什么?

4

1 回答 1

3

appStoreReceiptURL是一种用于提供执行收据验证所需收据的方法 ( Docs )

您描述的显示exit(173)代码的方法特定于 OSX,不应在 iOS7 上使用。如果无法在路径中加载收据,则使用此代码退出应用程序将使 OSX 尝试刷新收据。

对于 iOS7(在 iOS7 之前不可用),您应该改用SKReceiptRefreshRequest该类。这将强制刷新收据。

于 2013-12-04T00:04:30.660 回答