Office及VBA技术交流

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1378|回复: 1

关于IAP:苹果的审核规则发生了一点变化--没有“恢复”将...

[复制链接]

该用户从未签到

18

主题

23

帖子

110

积分

注册会员

Rank: 2

积分
110
发表于 2016-5-11 23:09:58 | 显示全部楼层 |阅读模式
本帖最后由 Unity 于 2016-5-12 20:39 编辑

We found that while your app offers In-App Purchase(s) that can be restored, it does not include the required "Restore" feature to allow users to restore the previously purchased In-App Purchase(s), as specified in Restoring Transactions section of the In-App Purchase Programming Guide:

"...if your application supports product types that must be restorable, you must include an interface that allows users to restore these purchases. This interface allows a user to add the product to other devices or, if the original device was wiped, to restore the transaction on the original device."

To restore previously purchased In-App Purchase products, it would be appropriate to provide a "Restore" button and initiate the restore process when the "Restore" button is tapped by the user.

For more information about restoring transactions and verifying store receipt, please refer to the In-App Purchase Programming Guide.


大体意思就是应用需要一个购买恢复的功能,第一次做的IAP并没有做这个功能,但也通过了,可能是苹果新增的审核规则。
解决方法很简单,增加一个Restore按钮,并调用[[SKPaymentQueue defaultQueue] restoreCompletedTransactions],接下来的流程是
1,弹出对话框输入帐号信息
2,如果点击“取消”,调用方法
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
如果点击“确定”,开始请求数据
3,返回数据后,回调
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
4,判断交易队列中交易的状态,在状态为“SKPaymentTransactionStateRestored”的switch分支下调用恢复处理方法
5,恢复完成后回调-(void)completeTransaction:(SKPaymentTransaction *)transaction
本文出自 “驴车手的旅程” 博客,请务必保留此出处http://hillboy.blog.51cto.com/1645730/946243


一旦交易处理完成,并从队列中移除,应用通常不会再看到它。但是如果应用支持的product类型必须可还原,你就必须包含一个接口,允许用户还原这些购买。这个接口允许用户把已购买的product添加到其它设备,或者原始设备重置后,也需还原交易。 Store Kit提供内建的机制,用于还原非消耗型、自动再生订阅、免费订阅等product的交易。应用调用payment队列的restoreCompletedTransactions方法,payment队列就会发送一个请求到App Store来还原交易。而App Store则对所有之前已经完成的交易生成一个新的还原交易。还原交易对象的originalTransaction属性保存了原始的交易。应用对还原交易进行处理,从中获取原始交易,然后使用这个原始交易对象来解锁用户已购买的内容。在Store Kit还原了之前完成的交易时,会通知payment队列的observer对象,并调用它的paymentQueueRestoreCompletedTransactionsFinished: 方法。 如果用户试图购买一个可还原的product(而不是使用你实现的还原接口),应用会接收到一个正常的交易,而不是可还原交易。但是用户不需要再次为这个product支付。应用应该把这些交易当作原始交易一样来处理。 非自动再生订阅和可消耗型product不会被Store Kit自动还原。但是非自动再生订阅又必须可还原,因此在购买这些product时,你必须在自己的服务器上记录这些交易,并提供自己的机制来还原这些交易给用户的所有设备。
回复

使用道具 举报

该用户从未签到

18

主题

23

帖子

110

积分

注册会员

Rank: 2

积分
110
 楼主| 发表于 2016-5-12 20:41:47 | 显示全部楼层
Greg Heo
Restoring In-app Purchases
On the pesky requirement of having a "Restore Purchases" button in your iOS app.

16 August 2012 • Tags: iOS
I’ve noticed a bit of chatter on the Internets about this bit in Apple’s In-App Purchase Programming Guide:

…if your application supports product types that must be restorable, you must include an interface that allows users to restore these purchases
What the heck? Where am I supposed to find room for a “Restore” button in my app, you ask? Luckily, that’s your problem; what I’ll talk about here is how to handle the implementation.

Regular In-app Purchase

Let’s go over the basics of the simplest purchase before talking about the restore procedure:

SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"productId"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
StoreKit will take over and if all is well, your transaction observer (self in this case) will receive a call to this method:

- (void)paymentQueue:(SKPaymentQueue *)queue
updatedTransactions:(NSArray *)transactions
The transactions array will contain SKPaymentTransaction objects, each with a transactionState property. This will usually be SKPaymentTransactionStatePurchased for a successful purchase.

Anyhow, you already know all this. Let’s talk about the dreaded restore.

The Restoration

The general workflow is pretty similar. Rather than “purchase” a specific product, send the restoreCompletedTransactions message to the queue.

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
Again, StoreKit will take over and call paymentQueue:updatedTransactions: for each restored purchase. These will look an awful like regular purchases except the transactionState will be SKPaymentTransactionStateRestored. The original transaction details are available in transaction.originalTransaction.

Once all the paymentQueue:updatedTransactions: calls are made, the transaction observer will receive this callback:

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
If something goes wrong (StoreKit error, invalid password, user hits “Cancel”, etc.) you’ll receive this callback instead:

- (void)paymentQueue:(SKPaymentQueue *)queue
  restoreCompletedTransactionsFailedWithError:(NSError *)error
Implementation Details

For a simple app, say with a single “unlock app” kind of in-app purchase, it would be easy to handle the various use cases:

If the app is already unlocked, we don’t even need to show the “Restore” button. Easy!

If the app hasn’t been unlocked and we receive the paymentQueue:restoreCompletedTransactionsFailedWithError: message, show an error alert to the user.

If the app hasn’t been unlocked, we receive the paymentQueueRestoreCompletedTransactionsFinished: message, and the app still isn’t unlocked, show a “Sorry, no previous purchases could be restored” kind of message.

If the app hasn’t been unlocked, we receive the paymentQueueRestoreCompletedTransactionsFinished: message, and the app is now unlocked, show a “Restore successful!” kind of message.

In Closing

Apps with more complicated IAP usage might need more complicated IAP restore procedures, but I hope this is a good start.

© Copyright 2009–2016 Greg Heo • Made in Toronto • [super dealloc];
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Office Master ( 蜀ICP备16003423号 )

GMT+8, 2019-7-18 13:02 , Processed in 0.381510 second(s), 23 queries .

Office Master

快速回复 返回顶部 返回列表