gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 17:12:42 26 4
gpt4 key购买 nike

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

2.2 The app is still not using the Store Kit API properly. It is not grabbing the pricing information from the App Store's server (see screenshot). Using Store Kit, the application should send a request to the App Store to retrieve a list of product identifiers that are currently available for purchase. Once the application receives this list, it should display only those products that are flagged as available for purchase. The application is not making this request to the App Store and is instead displaying products that are returned directly by your server.

这是截图

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

最佳答案

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

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

因此,我将使用 productsRequest:didReceiveResponse: 来更新或创建显示待售商品的 View :

- (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 协议(protocol):

[[SKPaymentQueue defaultQueue] addTransactionObserver:someObjectProbablySelf];

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

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

关于cocoa - 应用程序未正确使用 Store Kit API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17132805/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com