应用程序未正确使用Store Kit API

时间:2013-06-16 11:27:39

标签: cocoa storekit in-app-purchase

我有一个被拒绝的应用程序,动机说:

  

2.2       该应用仍未正确使用Store Kit API。它没有从App Store的服务器获取定价信息(见截图)。   使用Store Kit,应用程序应向App Store发送请求,以检索当前可供购买的产品标识符列表。应用程序收到此列表后,应仅显示标记为可供购买的产品。该应用程序不会向App Store发出此请求,而是显示由您的服务器直接返回的产品。

这是截图

enter image description here

我真的不明白我需要做什么......对我而言,一切都工作正常,我也不明白为什么他们说“产品直接由我的服务器返回”......不是那样的....我会告诉你我的代码:

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    if(response.products.count > 0)
{
    SKProduct* product;

    for(int i = 0; i<response.products.count; i++)
    {
        product = [response.products objectAtIndex:i];

        if([product.productIdentifier isEqualToString:@"com.mySite.MyApp.1"] || [product.productIdentifier isEqualToString:@"com.mySite.MyApp.2"] || [product.productIdentifier isEqualToString:@"com.mySite.MyApp.3"] || [product.productIdentifier isEqualToString:@"com.mySite.MyApp.4"] || [product.productIdentifier isEqualToString:@"com.mySite.MyApp.5"])
        {
            self.currentProduct = product;
            [self beginPaymentWithProduct:product];
        }
    }
  }
 }


- (void)beginPaymentWithProduct:(SKProduct*)product
{
    SKPayment *payment = [SKPayment paymentWithProduct:product];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
}


- (BOOL)canMakePurchases
{
    return [SKPaymentQueue canMakePayments];
}


- (IBAction)buyProduct1:(id)sender
{
   if([self canMakePurchases])
   {
     self.prodottoScelto = @"1";
    [moneteAcquistateLabel setStringValue:@"25"];
    ualRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet   setWithArray:[NSArray arrayWithObjects: @"com.mySite.MyApp.1", nil]]];
    [ualRequest setDelegate:self];
    [ualRequest start];
    }

}


 - (IBAction)buyProduct2:(id)sender
  {
    //same code as below
  }


  - (IBAction)buyProduct3:(id)sender
     {
      //same code as below
     }


   - (IBAction)buyProduct4:(id)sender
     {
      //same code as below
     }


    - (IBAction)buyProduct5:(id)sender
    {
      //same code as below
     }



      - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
        {
          for (SKPaymentTransaction* transaction in transactions) {
           if (transaction.transactionState == SKPaymentTransactionStatePurchased) {


            //    NSLog(@"Transaction Purchased: %@", transaction);

            // Make purchase available to the user, etc...

           //assegno le monete acquistate all'utente
            if ([prodottoScelto isEqual:@"1"])
              {                
            //  NSLog(@"prodotto 1 sbloccato");
            [self aggiornaMonete:25];
        }
        else if ([prodottoScelto isEqual:@"2"])
        {
            //  NSLog(@"prodotto 2 sbloccato");
            [self aggiornaMonete:60];
        }
        else if ([prodottoScelto isEqual:@"3"])
        {
            //  NSLog(@"prodotto 3 sbloccato");
            [self aggiornaMonete:105];
        }
        else if ([prodottoScelto isEqual:@"4"])
        {
            //  NSLog(@"prodotto 4 sbloccato");
            [self aggiornaMonete:160];
        }
        else if ([prodottoScelto isEqual:@"5"])
        {
            //  NSLog(@"prodotto 5 sbloccato");
            [self aggiornaMonete:225];
        }

        // Once that's all done...
        [queue finishTransaction:transaction];


    }
    else if (transaction.transactionState == SKPaymentTransactionStateFailed) {

        //NSLog(@"Transaction Failed: %@", transaction);
        // Display error to the user, using the error text in the transaction
        // This example uses NSLog, typically you'd use UIAlertView here
        //  NSLog(@"Error: %@", [transaction.error localizedDescription]);
    }
   }
  }

我应该添加什么?这个相同的代码在iOS应用程序中运行良好... 谢谢你的帮助

1 个答案:

答案 0 :(得分:1)

审核人可能认为您正在从服务器检索产品列表,但实际上您的产品实际上是硬编码到您的应用中。显然他只是猜到了。

无论如何,您应该从应用商店中检索产品列表,并在应用中显示商店的价格值。我想这只是为了确保您在itunesconnect中创建的产品与您在应用中提供的产品之间不存在任何不一致。这个“内置产品模型”有一个很好的序列图:In-App Purchase Programming Guide

因此,我会使用productsRequest:didReceiveResponse:更新或创建显示待售商品的视图:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSArray *skProducts = response.products;
    for (SKProduct *skProduct in skProducts) {
        NSLog(@"Found product: %@ %@ %0.2f",
              skProduct.productIdentifier,
              skProduct.localizedTitle,
              skProduct.price.floatValue);
    }
}

但在此之前,您必须告诉应用商店您期望的产品(内置产品型号):

productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObjects:@"com.makemyday.appy.product", nil]];
productsRequest.delegate = someObjectProbablySelf;
[productsRequest start];

现在有人可以从商店购买价格和标题的产品:

- (void)buyProduct:(SKProduct *)product {
    SKPayment *payment = [SKPayment paymentWithProduct:product];
    [[SKPaymentQueue defaultQueue] addPayment:payment];    
}

此外,您应该分配一些对象来观察事务队列以监视已完成或失败的事务,实现SKPaymentTransactionObserver协议的事务:

[[SKPaymentQueue defaultQueue] addTransactionObserver:someObjectProbablySelf];

这些只是我从这个tutorial收集的最重要的片段(对于iOS,但对OSX来说也应该没问题。)

为什么它适用于iOS?可能是您的iOS应用程序的审阅者没有注意到。