我应该何时验证应用内购买交易收据? [英] When should i validate in-app purchase transaction receipt?

查看:95
本文介绍了我应该何时验证应用内购买交易收据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是,我的步骤应该是什么?

I mean, should my steps be?


1)获取 SKPaymentTransactionStatePurchased

2)从SKPaymentQueue中删除它并按 [[SKPaymentQueue defaultQueue]提供内容] finishTransaction:transaction];

2) Remove it from SKPaymentQueue and provide the content by [[SKPaymentQueue defaultQueue] finishTransaction: transaction];

3)验证收据然后,如果它无效,则阻止内容我刚刚提供了

3) Validate the receipt and then, if it's invalid, block the content i've just provided

或者我应该将第二步改为第三步?

Or should i change 2nd step to 3rd instead?


1)获取 SKPaymentTransactionStatePurchased

2)验证收据然后,如果它无效,则不提供内容

2) Validate the receipt and then, if it's invalid, dont't provide content

3)从中删除 SKPaymentQueue 无论如何 [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

在第一种情况下,用户可以转入购买后立即关闭ternet,因此我将无法验证收据。但在第二步,在第1步和第2步之间可能会出现互联网的一些问题,所以我不会完成交易,也不会提供内容,这将是糟糕的用户体验。

In first scenario user can turn the internet off right after the purchase, so i won't be able to validate the receipt. But in the second, there may occure some problems with internet between step 1 and 2, so i won't finish the transaction and won't provide the content, that would be a bad user experience.

那你选择了什么样的应用程序?为什么?

So what way did you choose for your app and why?

我的选择

我选择了第二种情况,因为选择第一种方案会让我的应用程序很容易被iAP Cracker破解。

I've choosen the second scenario, since choosing the first one makes my app be easily cracked by iAP Cracker.

推荐答案

场景2.
如果互联网爆炸,你将无法进入-finishTransaction。
但这很酷,因为你可以重试(NSTimer),你的应用程序将在启动时获得未完成的交易。
这就是完全 StoreKit的设计方式(尽管从阅读文档中看不出来)。

Scenario 2. If the internet blows up, you won't get to -finishTransaction. But that's cool, cause you can retry (NSTimer) and your app will be given the unfinished transaction on start up. And that's exactly how StoreKit is designed to work (even though it's not obvious from reading the docs).

StoreKit随附交易,有充分理由。用户可以在购买后立即退出应用程序,您仍然需要从中恢复。
这就是为什么Apple建议在应用程序生命周期中尽快设置您的事务观察器。

StoreKit comes with transactions, for a good reason. The user can simply quit the app right after purchasing, and you still have to recover from that. And that's why Apple recommends to set your transaction observer as soon as possible in the app lifecycle.

在提供内容之前,不要完成事务,你必须在StoreKit之上实现你自己的交易系统,你不想那样做,相信我(我已经看过它,这是一场灾难)。

Don't ever finish the transaction before providing the content, you'll have to implement your own transaction system on top of StoreKit, and you don't want to do that, believe me (I've seen it done, it was a disaster).

编辑:老实说,用户最终在购买之后和验证之前关闭了互联网,这是非常低的。这家伙在一秒钟之前上网了,没有人只是在购买过程中出去切断互联网。
但是当时用户可能会被打断并将您的应用程序发送到后台。
您的应用程序可能因iOS认为合适的原因而被杀死。
当你的应用程序再次启动时,你的应用程序将不会记得开始购买,并且商店套件不会有很大的帮助,因为你已经完成了交易。

in all honesty, the eventually of a user turning the internet off after purchase and before you validate is ridiculously low. The guy was on they internet a second ago, nobody just goes out to cut the internet in the middle of a purchase. But it's possible that the user gets interrupted at that the moment and send your app to the background. Your app can then get killed for whatever reason iOS deems appropriate. And when you're apps starts again, well your app won't remember having a purchase to start with, and store kit won't be of big help, since you've already finished the transaction.

这篇关于我应该何时验证应用内购买交易收据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆