ios7 – 非续订订阅:从收据中删除?

我正在为我的应用(即将发布)实施应用内购买,并为iOS6和iOS7提供支持.我的问题与iOS6和iOS7之间的不更新订阅机制的差异有关,更具体地说就是如何实现还原.为了兼容iOS6和iOS7,我实现了一个服务器端解决方案来启用还原.我可以选择允许用户创建一个用户名/密码,可以在不同的设备上使用(如果数据丢失,则使用相同的设备)进行还原.我的大部分工作基本上都是工作的,但是随着我的测试进展顺利,我发现好奇.

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

而下表(https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Products.html)

任何人有任何见解?

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上.现在看来,我们现在回到“正常”,不用续订.也就是说,当我进行恢复时,我再次收到收据中的非续订订阅.

解决方法

请注意,在应用收据中持续不更新订阅不保证被App Store评论者接受.成功取决于具体的审阅者.我最近收到了苹果的消息:

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];

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...