单击 IAP 并使用新视图

发布于 2024-12-27 16:45:59 字数 336 浏览 1 评论 0原文

大家好,我正在尝试弄清楚这个 IAP 教程,我只想用我的内容制作一个简单的应用程序,而不是在应用程序商店中充斥大量较小的应用程序。

http://www.raywenderlich.com/2797/introduction-to-in -app-purchases

我一直在学习这个教程,我只需要有人在点击支票购买并且交易完成后帮助我我希望它将他们带到一个新的视图控制器可以有人帮我解决这个问题吗?

提前致谢 :)

Hey guys I am trying to figure out this IAP tutorial I would like to just make one simple app with my content instead of flooding the app store with a lot of smaller apps.

http://www.raywenderlich.com/2797/introduction-to-in-app-purchases

I have been going through this tutorial, I just need someone to help me after the person clicks the check to purchase and the transaction goes through I want it to take them to a new view controller could anyone help me with this?

Thanks in advance :)

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

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

发布评论

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

评论(1

蓝梦月影 2025-01-03 16:45:59

根据您的评论,我相信一旦购买了内容,您就会想要显示新的视图
所以这里是该代码

1)这是交易的主要代码

- (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];
                break;
            default:
                break;
        }
    }
}

2)由于您正在检查付款是否成功:您的情况是SKPaymentTransactionStatePurchased:

以下方法将被称为

- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
    [self provideContent:transaction.payment.productIdentifier];
    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}

3) 在提供内容方法中,您必须显示您的观点:

- (void)provideContent:(NSString *)productId
{
    if ([productId isEqualToString:kInAppPurchaseProUpgradeProductId])//kInAppPurchaseProUpgradeProductId is your IAP id in iTunes Connect
    {
     //Your code goes here;
    }
}

Based on your comment i believe once the content is purchased then you want to show a new view
So here is the code for that

1) This is The Main Code for the transaction

- (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];
                break;
            default:
                break;
        }
    }
}

2) Since you are checking for successful payment : your case is SKPaymentTransactionStatePurchased:

The following method will be called

- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
    [self provideContent:transaction.payment.productIdentifier];
    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}

3) In the Provide Content Method you have to show your view :

- (void)provideContent:(NSString *)productId
{
    if ([productId isEqualToString:kInAppPurchaseProUpgradeProductId])//kInAppPurchaseProUpgradeProductId is your IAP id in iTunes Connect
    {
     //Your code goes here;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文