【问题标题】:In app purchase not working when moderator review my app版主审核我的应用时,应用内购买不起作用
【发布时间】:2014-10-04 13:06:17
【问题描述】:

我是第一次使用 IAP。我已经创建了测试用户并且在沙盒环境中运行良好。我也可以看到我的购买并购买(当然我添加了 StoreKit 框架。),但问题是:当我使用 IAP 将更新上传到 AppStore 时 - 版主拒绝了我的应用,原因如下:

我们发现,虽然您已为您的应用提交应用内购买产品,但应用内购买功能并未出现在您的二进制文件中。请参阅随附的屏幕截图以获取更多信息。(屏幕上没有一些购买,而是空白)

如果您想在您的应用中使用 In App Purchase,您需要上传一个包含 In App Purchase API 的新二进制文件,以使用户能够进行购买

我只是不明白这怎么可能?为什么当我测试 IAP 时 - 它工作正常,但当版主这样做时它不起作用?所有 IAP 均处于“已批准出售”和“等待审核”状态

现在,如果我将应用程序上传到商店,IAP 会起作用吗?或者我之前需要做一些额外的动作?

这是我的代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    _iapArray = [[NSMutableArray alloc] init];
    iap1 = @"com.mypurchase.addcoins1";

    [self paymentCheck];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
}

- (void)paymentCheck{

    if([SKPaymentQueue canMakePayments]){
        NSLog(@"User can make payments");

        SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObjects:iap1, nil]];
        productsRequest.delegate = self;
        [productsRequest start];

    }
    else{
        NSLog(@"User cannot make payments due to parental controls");
        //this is called the user cannot make payments, most likely due to parental controls
    }
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
    SKProduct *validProduct = nil;
    int count = [response.products count];
    if(count > 0){

        _iapArray = response.products;
        indicator.hidden = YES;
        [self.tableView reloadData];
    }
    else if(!validProduct){
        NSLog(@"No products available");

        UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                              message:@"Error"
                                                             delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [myAlertView show];
        //this is called if your product id is not valid, this shouldn't be called unless that happens.
    }
}


- (IBAction)purchase:(SKProduct *)product{
    SKPayment *payment = [SKPayment paymentWithProduct:product];
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
}

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
    for(SKPaymentTransaction *transaction in transactions){
        switch (transaction.transactionState){
            case SKPaymentTransactionStatePurchasing: NSLog(@"Transaction state -> Purchasing");
                //called when the user is in the process of purchasing, do not add any of your own code here.
                break;
            case SKPaymentTransactionStatePurchased:
                //this is called when the user has successfully purchased the package (Cha-Ching!)
                // [self doRemoveAds]; //you can add your code for what you want to happen when the user buys the purchase here, for this tutorial we use removing ads
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                NSLog(@"Transaction state -> Purchased - %@", transaction.payment.productIdentifier);

                if ([transaction.payment.productIdentifier isEqualToString:iap1]) {
                    [self addCoins:5];
                }

                break;
            case SKPaymentTransactionStateRestored:
                NSLog(@"Transaction state -> Restored");
                //add the same code as you did from SKPaymentTransactionStatePurchased here
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                //called when the transaction does not finnish
                if(transaction.error.code != SKErrorPaymentCancelled){
                    NSLog(@"Transaction state -> Cancelled");
                    //the user cancelled the payment ;(
                }
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                break;
        }
    }
}

【问题讨论】:

  • 我怀疑评论者不知道如何在您的应用中进行购买。应用内购买截图是否清楚地显示了如何访问您的商店?是否清楚如何在您的应用中进行购买?
  • 在您的 iTunes Connect 中检查应用内购买的状态?是否处于待售状态?查看它的产品 ID。
  • 不,他们知道如何在我的应用程序中进行购买,但是当他们使用 IAP 打开视图时 - 他们没有出现,只是错误 - 我猜 - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse 方法返回无效产品 :( 当我上传构建以供审核时,IAP 处于“等待审核”状态 - 对吗?
  • 您是否同时提交了您的 IAP 产品以供审核(例如,它们已附加到提交版本)?这是第一次不一定很明显的步骤,可能会导致审查中“没有有效的产品”,但在沙盒中一切正常。如果您不知道我指的是什么,一旦您输入了 IAP 条目,您必须前往 iTC 中 app 的应用内购买部分进行连接。跨度>

标签: ios objective-c xcode in-app-purchase appstore-approval


【解决方案1】:

根据他们的回复,您已将 IAP 集成到应用程序中,但您尚未使用它。那么,您能否确保您已将 IAP 正确集成到应用程序中?如果他们提到,请在相同的设备和 iOS 中测试。

【讨论】:

  • 感谢您的回答!我更新了我的问题(添加了实现 IAP 的代码),是否足以制作 IAP?或者我还需要添加什么 API?我已经添加了 StoreKit.framework 并编写了一个代码,它实现了 IAP,它在我的带有演示帐户的设备上运行良好,也许我错过了什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-21
  • 1970-01-01
  • 1970-01-01
  • 2017-08-05
  • 1970-01-01
相关资源
最近更新 更多