iPhone 应用内购买:如何使用 storekit 检测未完成的交易?

发布于 2024-08-09 14:20:39 字数 700 浏览 1 评论 0原文

我正在 iPhone 应用程序中实现应用内购买,该应用程序允许下载大量数据。

现在,我试图弄清楚商店工具包是否可以告诉我是否有任何交易已完成购买,但已因应用程序关闭而中断。

据我所知,执行此操作的唯一方法是将观察者添加到 SKPaymentQueue:

[[SKPaymentQueue defaultQueue] addTransactionObserver:someObject];

并等待 defaultQueue 调用

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

someObject。当此方法是时,处于上述中断状态的项目在交易数组中显示为 SKPaymentTransactionStatePurchased

我解决此问题的第一次尝试是添加我的观察者,然后要求:

[SKPaymentQueue defaultQueue].transactions

并检查它们。据称,这会返回一组“待处理”交易,但根据我的经验,不包括 SKPaymentTransactionStatePurchased 中的交易。

我希望使用 storekit 来维持这种状态,并且喜欢任何想法。谢谢。

I'm implementing in-app purchase in an iphone application that allows for downloading of a non-trivial amount of data.

Right now, I'm trying to figure out if the Store Kit can tell me if there are any transactions where the purchase is complete, but that have been interrupted by application shutdown.

As far as I can tell the only way to do this is to add an observer to the SKPaymentQueue:

[[SKPaymentQueue defaultQueue] addTransactionObserver:someObject];

and wait for the defaultQueue to call

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

on someObject. Items that are in the interrupted state above show up in the transactions array as SKPaymentTransactionStatePurchased when this method is

My first attempt at solving this problem was to add my observer and then ask for:

[SKPaymentQueue defaultQueue].transactions

and inspect those. This allegedly returns an array of 'pending' transactions, but in my experience doesn't include transactions that are in SKPaymentTransactionStatePurchased.

I was hoping to use the storekit to maintain this state and would love any ideas. Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2024-08-16 14:20:39

我认为单独使用商店套件不可能做到这一点,所以我在 sqlite 中制作了一个小表:

create table purchased_products (
  product_identifier text primary key, -- apple store id string
  purchased integer not null           -- 1 if purchased
);

当我收到 SKPaymentQueue 回调表明产品已购买时,我向该表添加一行。

它工作得很好。

I decided that it was impossible to do this using store kit alone so I made a small table in sqlite:

create table purchased_products (
  product_identifier text primary key, -- apple store id string
  purchased integer not null           -- 1 if purchased
);

and when I get the SKPaymentQueue callback indicating that a product has been purchased I add a row to this table.

It's working just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文