【问题标题】:App is not using Store Kit API properly应用程序未正确使用 Store Kit API
【发布时间】:2013-06-25 17:21:08
【问题描述】:

我有一个正在审核的应用被拒绝,动机说:

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

这是截图

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

-(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应用程序中运行良好...... 感谢您的帮助

【问题讨论】:

    标签: cocoa storekit in-app-purchase


    【解决方案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 中收集到的最重要的 sn-ps(对于 iOS,但对于 OSX 也应该没问题)。

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

    【讨论】:

    • 嘿!非常感谢您的回答...明天我会试一试...因为此时我的工作时间已经结束...再次感谢...如果它有效,请告诉您。和平马西
    • 对不起,user511,但我不清楚如何将您的代码与我的代码集成....如您所见,我有多种产品...您能告诉我将您的代码放在哪里以及如何拥有所有 5 种产品?我知道我问了很多,但我真的对这件事感到迷茫......并且非常感谢你的努力......非常感谢...... Massy
    • 我只会将它添加到您现有的代码中,或者将其全部放入管理应用内购买的自己的单例类中。关于您的 5 个产品:将它们添加到 SKProductsRequest 初始化程序中的 NSSet 初始化程序。 (你真的应该查看我答案末尾的教程链接。在那里你会找到一个分步指南。)
    猜你喜欢
    • 1970-01-01
    • 2018-11-20
    • 2012-12-21
    • 2017-08-20
    • 2021-12-15
    • 2017-08-07
    • 2015-01-11
    • 2014-07-06
    • 1970-01-01
    相关资源
    最近更新 更多