【发布时间】:2014-04-03 17:26:02
【问题描述】:
我正在将 IAP 添加到我在 Mac App Store 上分发的 Mac 应用程序中。它似乎在我的 Mac 内部/外部 XCode 上本地运行良好,但由于某种原因,它不适用于具有不同行为(SIGKILL 或不下载 App Store 收据)的其他 Mac 计算机。
这是我用来确保 App Store 收据存在或正确下载的代码:
void EnsureAppstoreReceipt()
{
// TODO: Note: In OS X, if the appStoreReceiptURL method is not available (on older systems), you can fall back to a hardcoded path.
// The receipt’s path would be /Contents/_MASReceipt/receipt inside the app bundle.
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if(!receipt)
{
// Validation fails
qDebug() << "No AppStore receipt found. Exiting with 173 to force OSX to generate one in " << QString::fromNSString(receiptURL.absoluteString);
exit(173);
}
}
我在 XCode 中Archive 应用程序,然后选择Distribute,然后选择Application。如果我选择Don't resign,那么即使在我的电脑上,它也不会下载 App Store 收据。但是,如果我选择“Mac Appstore Distribution”身份或“Mac Development”配置文件,那么它会在我的开发 Mac 上正确加载收据,但在其他计算机上不起作用。它启动应用程序并始终以代码 173 退出,仅此而已。
是否可以在尚未构建应用程序的 Mac 上的沙盒中测试 IAP?如果是这样,我在这里错过了什么?
【问题讨论】:
标签: macos in-app-purchase mac-app-store