iphone store kit:如何捕获取消事件

发布于 2024-08-12 06:59:59 字数 341 浏览 9 评论 0原文

这是我的问题:

当使用 storekit 进行应用内购买时,我显示一个“正在加载”视图,告诉用户在该过程正在进行时等待几秒钟;但假设同一个用户,当 storekit 询问他的 itunes 帐户密码时,请按“取消”按钮...我如何“捕获”此事件以隐藏加载视图?

恐怕这可能会成为苹果拒绝的一个原因,因为用户的沟通非常重要。

感谢您的任何提示!

编辑:我没有在这里进行交易;我的第一步是恢复已完成的交易,以便通过此方法触发密码提示:

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]

Here's my problem :

When using storekit for in-app purchase, i'm displaying a "loading" view to tell the user to wait for a few seconds while the process is in progress; but let's say this same user, when the storekit ask him for his itunes account password, press the "cancel" button... How can i "catch" this event in order to hide the loading view?

I'm afraid it could be a cause of rejection for Apple since user's communication is pretty important.

Thanks for any tips!

Edit : I'm not in a transaction here; my first step is to restore completed transactions so the password prompt is trigger by this method :

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]

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

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

发布评论

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

评论(2

身边 2024-08-19 06:59:59

苹果开发论坛中也报告了类似的情况。

当用户要求恢复后点击取消时会发生什么......

在他们的例子中,复制并粘贴文档中的方法会产生一个错误,该错误显然编译时没有错误。

// wrong, but compiles
- (void)paymentQueue:(SKPaymentQueue *)queuerestoreCompletedTransactionsFailedWithError:(NSError *)error

而不是

// correct
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

如果您的观察者方法类似于上面的第一个方法,那么您可能没有收到恢复操作的失败消息。

更新:

SKPaymentTransactionObserver的SDK文档中,我看到了OS 3.1(2009-11-17)的恢复失败方法,但3.0文档(2009-05-01)似乎没有它。奇怪的是,3.1 文档声明此观察者方法“在 iPhone OS 3.0 及更高版本中可用”。

可以肯定的是。我检查了 iPhoneOS3.0.sdk/System/Library/Frameworks/StoreKit.framework/Headers/SKPaymentQueue.h 的副本,以确保恢复失败观察器方法存在。 (这是。)

Something similar was reported in the Apple dev forums.

What happens when user hits Cancel after asking to restore......

In their case, a copy-and-paste of a method from the documentation created a bug that apparently compiled without error.

// wrong, but compiles
- (void)paymentQueue:(SKPaymentQueue *)queuerestoreCompletedTransactionsFailedWithError:(NSError *)error

instead of

// correct
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

If your observer method looks like the first one above, then you're probably not receiving the failure message for the restore operation.

Update:

In SDK documentation for SKPaymentTransactionObserver, I see the restore failure method for OS 3.1 (2009-11-17) but 3.0 documentation (2009-05-01) doesn't seem to have it. Strange since the 3.1 doc states this observer method is "Available in iPhone OS 3.0 and later".

To be sure. I checked my copy of iPhoneOS3.0.sdk/System/Library/Frameworks/StoreKit.framework/Headers/SKPaymentQueue.h to make sure the restore failure observer method is there. (It is.)

你曾走过我的故事 2024-08-19 06:59:59

如果用户单击取消按钮,则请求将失败 - 使用像这样的商店观察者......

MyStoreObserver *observer = [[MyStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

并像这样处理......

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}

If the user clicks the cancel button then request will fail - use a store observer like so...

MyStoreObserver *observer = [[MyStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

And handle like this....

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文