iOS7的恢复过程的初始部分使用SKReceiptRefreshRequest刷新应用程序中的收据.当我从iOS7设备中删除应用程序时,重新安装(此时没有收据,使用iExplorer进行测试),并进行恢复,SKReceiptRefreshRequest将恢复10次购买(我在测试期间为此特定用户创建的购买) .其中一个是不可消耗的,其中九个是不更新的.这让我很困惑从苹果文档中,我预计只有在刷新的收据中才能看到不可消费的购买.从https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html:
“Consumable Products and Non-Renewing Subscriptions: The in-app
purchare receipt for a consumable product or a non-renewing
subscription is added to the receipt when the purchase is made. It is
kept in the receipt until your app finishes that transaction.
After that point,it is removed from the receipt the next time the
receipt is updated—for example,when the user makes another purchase
or if your app explicitly refreshes the receipt.”
关于不更新订阅,从https://developer.apple.com/in-app-purchase/In-App-Purchase-Guidelines.pdf:
Use iCloud or your own server to track purchases and allow user to
restore purchased subscriptions to all iOS devices owned by a single
user
任何人有任何见解?
Question: Why does SKReceiptRefreshRequest leave purchases for non-renewing products in the receipt? Is this a bug in the Apple docs
or is there something else going on?
14年2月23日;更新:我最近向苹果公司提交了一个错误报告.还没有回头虽然,实际上我不希望这个“bug”消失!
15年10月20日;更新:似乎苹果已经解决了这个“bug”.现在,当我使用SKReceiptRefreshRequest(似乎是Apple的推荐方法进行恢复时,请参阅https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html)进行恢复,现在我没有收到在收据中显示的非续订订阅.我只得到非耗材(我的应用程序只有非更新订阅和非消耗品购买).在我至少写这个文件之后,我会立即向苹果提交错误报告,他们的文档对预期的行为是不明确的.
到目前为止,我的测试包括我的应用程序运行在iOS 8.4和iOS9(9.1 beta实际上,因为我没有正确的设备运行生产版本),所以看起来这是一个服务器端的变化与苹果,而不是严格讲iOS /设备端更改.还要注意的是,我迄今为止所有的测试都是在我的应用程序的开发构建中,而且在应用内购买沙箱也是如此.我将在短时间内进行生产测试.
15年12月3日;更新;在苹果技术支持部门的提示下,我进行了一些测试.这一次,在运行iOS9.2 beta 4(13C75)的iPad上.现在看来,我们现在回到“正常”,不用续订.也就是说,当我进行恢复时,我再次收到收据中的非续订订阅.
解决方法
We found that your app includes a feature to restore prevIoUsly
purchased In-App Purchase products by entering the user’s Apple ID and
password. However,Non-Renewing Subscription In-App Purchases cannot
be restored in this manner.It would be appropriate to revise your binary to remove this feature.
If you would like users to be able to restore Non-Renewing
Subscription In-App Purchase products,you will need to implement your
own restore mechanism.
所以最后一次尝试提交该应用程序是不幸的.不像以前的几个.
现在,我的计划是将应用收据存储在iCloud Key-Value Storage上,并自动恢复所有的购买.它会满足苹果的要求:
For non-renewing subscriptions,use iCloud or your own server to keep
a persistent record.
(c) Store Kit Programming Guide
以下是为这些目的提供的Apple代码:
#if USE_ICLOUD_STORAGE NSUbiquitousKeyValueStore *storage = [NSUbiquitousKeyValueStore defaultStore]; #else NSUserDefaults *storage = [NSUserDefaults standardUserDefaults]; #endif NSData *newReceipt = transaction.transactionReceipt; NSArray *savedReceipts = [storage arrayForKey:@"receipts"]; if (!receipts) { // Storing the first receipt [storage setObject:@[newReceipt] forKey:@"receipts"]; } else { // Adding another receipt NSArray *updatedReceipts = [savedReceipts arrayByAddingObject:newReceipt]; [storage setObject:updatedReceipts forKey:@"receipts"]; } [storage synchronize];