iPhone 应用程序内购买 - 响应。产品仍然是空的?

发布于 2024-08-18 19:48:36 字数 2397 浏览 8 评论 0原文

基本上,我尝试在测试应用程序上设置应用程序内购买,然后将它们实施到我公司正在开发的适当应用程序中。我已经阅读了商店套件 pdf 和其他片段大约 1000 遍,但产品仍然被退回为空。这正是我到目前为止所做的:

设置测试应用和应用内购买测试项目
我在 iPhone 开发中心的公司开发者门户上为“Test App One”创建了一个新的应用程序 ID。我确保前缀为 com.mycompany.testappone 以确保可以配置应用内购买。在“应用程序 ID”部分,我通过勾选“启用应用程序内购买”选项来配置应用程序内购买。

我在 iTunes Connect 中创建了“测试应用程序一”并完成了通常的过程,但选择了“稍后上传二进制文件”,并且没有提交审核,因为该应用程序不执行任何操作。当然,我们不必提交应用程序进行审核即可正常工作?!然后,我单击“应用程序内购买管理”,创建了一个产品 ID 为“test1”的新产品,并批准了它,以便可以销售。

代码
我在 XCode 中建立了一个名为 TestAppOne 的新项目,这是我现在使用的仅有的 2 个类:

TestAppOneAppDelegate.h:

#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>  

@interface TestAppOneAppDelegate : NSObject <UIApplicationDelegate, SKRequestDelegate, SKProductsRequestDelegate> {
    UIWindow *window;
}

TestAppOneDelegate.m:

#import "TestAppOneAppDelegate.h"

static NSString *kMyFeatureIdentifier1 = @"com.mycompany.testappone.test1";

@implementation TestAppOneAppDelegate
@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
 if([SKPaymentQueue canMakePayments]) {
  NSLog(@"IN-APP:can make payments");
 }
 else {
  NSLog(@"IN-APP:can't make payments");
 }

 [self requestProductData];
 [window makeKeyAndVisible]; 
}

- (void)requestProductData {
 NSLog(@"IN-APP:requestProductData");
 SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:kMyFeatureIdentifier1]];
 request.delegate = self; 
 [request start];
 NSLog(@"IN-APP:requestProductData END");  
} 

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
 NSLog(@"IN-APP:productsRequest");
 NSArray *myProduct = response.products;
 NSLog(@"IN-APP:array count: %i", [myProduct count]);
 [request autorelease];
 NSLog(@"IN-APP:productsRequest END"); 
}

- (void)dealloc {
    [window release];
    [super dealloc];
}

@end

在设备上测试< br> 我创建了一个沙盒测试帐户并在 iPhone 上注销了我的 iTunes 帐户,但没有使用测试帐户登录,因为文档告诉我们在购买阶段收到提示之前不要执行此操作。然后我构建了应用程序,这是我得到的日志:

IN-APP:can make payments
IN-APP:requestProductData
IN-APP:requestProductData END
IN-APP:productsRequest
IN-APP:array count: 0
IN-APP:productsRequest END

任何人都可以告诉我是否遗漏了任何阶段或者是否有任何我做错的事情。不幸的是,似乎没有任何苹果制作的示例应用程序。

Basically, I've tried to set up in app purchases on a test app before I implement them into a proper app that my company is working on. I've read the Store kit pdf and other snippets about a 1000 times, but the products are still being returned as empty. Here's exactly what I've done so far:

Setup test app and In App Purchase test items
I created a new app id for 'Test App One' on my company's developer portal in the iPhone Dev Centre. I made sure that the prefix was com.mycompany.testappone to ensure that in app purchases could be configured. Staying in the App IDs section, I configured in app purchases by ticking the 'Enable In App Purchase' option.

I created 'Test App One' in iTunes Connect and completed the usual procedure but selected 'upload binary later' and didn't submit for review as the app does nothing. Surely we don't have to submit the app to review for this to work?! I then clicked on manage in app purchases and created a new one with product id 'test1' and approved it so that it is cleared for sale.

Code
I set up a new project in XCode called TestAppOne and here are the only 2 classes I am using for now:

TestAppOneAppDelegate.h:

#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>  

@interface TestAppOneAppDelegate : NSObject <UIApplicationDelegate, SKRequestDelegate, SKProductsRequestDelegate> {
    UIWindow *window;
}

TestAppOneDelegate.m:

#import "TestAppOneAppDelegate.h"

static NSString *kMyFeatureIdentifier1 = @"com.mycompany.testappone.test1";

@implementation TestAppOneAppDelegate
@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
 if([SKPaymentQueue canMakePayments]) {
  NSLog(@"IN-APP:can make payments");
 }
 else {
  NSLog(@"IN-APP:can't make payments");
 }

 [self requestProductData];
 [window makeKeyAndVisible]; 
}

- (void)requestProductData {
 NSLog(@"IN-APP:requestProductData");
 SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:kMyFeatureIdentifier1]];
 request.delegate = self; 
 [request start];
 NSLog(@"IN-APP:requestProductData END");  
} 

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
 NSLog(@"IN-APP:productsRequest");
 NSArray *myProduct = response.products;
 NSLog(@"IN-APP:array count: %i", [myProduct count]);
 [request autorelease];
 NSLog(@"IN-APP:productsRequest END"); 
}

- (void)dealloc {
    [window release];
    [super dealloc];
}

@end

Testing on the device
I created a sandbox test account and logged out of my iTunes account on the iPhone, but didn't log in with the test account as the documentation tells us to not do this until we are prompted at the purchasing stage. I then build the app and here is the log I'm getting:

IN-APP:can make payments
IN-APP:requestProductData
IN-APP:requestProductData END
IN-APP:productsRequest
IN-APP:array count: 0
IN-APP:productsRequest END

Can anyone please tell me if I have left any stages out or if there is anything that I'm doing wrong. Unfortunately there doesn't seem to be any example apps made by Apple.

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

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

发布评论

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

评论(10

水染的天色ゝ 2024-08-25 19:48:36

另一个经常被忽视的重要步骤是,您需要确保您有一个 iOS 付费应用程序合同设置,该合同位于 iTunes connect 的“合同、税务和银行业务”部分下。首先您必须单击请求按钮,然后您必须单击 3 个设置按钮(联系信息、银行信息、税务信息)

Another important step that is often overlooked is you need to make sure you have an iOS Paid Applications Contract setup which is located under the "Contracts, Tax, and Banking" section of iTunes connect. First you have to click on the request button, then you have to click on the 3 Set Up buttons (Contact Info, Bank Info, Tax Info)

丘比特射中我 2024-08-25 19:48:36

实际上,我确实认为您必须提交二进制文件才能正常工作。

您可以将发布日期设置为遥远的未来。

Actually I do think you have to submit the binary for this to work.

You can set the release date to the distant future.

血之狂魔 2024-08-25 19:48:36

检查是否存在无效的产品 ID。

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

for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }
}

如果存在无效的产品 ID,请访问 http://troybrant.net/blog/ 2010/01/invalid-product-ids/

这是针对此问题的非常全面的检查清单。

编辑:(13/11/20)
网站似乎已关闭。我不确定这是否是一个永久性问题,但您可以从 archive.org 看到该页面:
https:/ /web.archive.org/web/20200212001158/http://troybrant.net/blog/2010/01/invalid-product-ids/

Check whether there are invalid product id's.

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

for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }
}

If there are invalid product ids visit http://troybrant.net/blog/2010/01/invalid-product-ids/

It is a very comprehensive check-list for this problem.

Edit: (13/11/20)
Site seems to be down. I'm not sure whether it is a permanent problem but you can see the page from archive.org:
https://web.archive.org/web/20200212001158/http://troybrant.net/blog/2010/01/invalid-product-ids/

蘸点软妹酱 2024-08-25 19:48:36

检查 XCode 中的捆绑标识符(例如 com.company.appname)是否与 iTunes Connect 中的捆绑标识符匹配。

您不必提交二进制文件即可使其工作。

Check if your Bundle Identifier (e.g. com.company.appname) in XCode matches the one in iTunes Connect.

You do not have to submit the binary for it to work.

笔芯 2024-08-25 19:48:36

只需删除设备上的应用程序,然后从 XCode 重新启动它即可。
它为我解决了问题。

在 iTunes Connect 中创建应用内购买后,无需上传二进制文件或等待数小时。

Just delete the application on your device, and start it again from XCode.
It fixed the problem for me.

No need to upload the binary, or wait for hours after creating the in-app purchase in iTunes Connect.

黎歌 2024-08-25 19:48:36

感谢 alpere 的回答,我发现我使用了错误的产品 ID。它不是,正如我所想的de.company.appname.PROFESSIONAL_LICENSE。在我的例子中,仅使用 PROFESSIONAL_LICENSE(不带前导包 ID 的东西)就可以了:)

Thanks to alpere's answer I found out that I used the wrong product ID. It was not as I thought de.company.appname.PROFESSIONAL_LICENSE. Just using PROFESSIONAL_LICENSE in my case (without leading bundle id stuff) works :)

女皇必胜 2024-08-25 19:48:36

无需上传二进制文件即可进行 InAppPurchase 的沙盒测试。您只需在 iTunesConnect 中添加 InAppPurchase 项目并将其置于“准备提交”(必须)状态即可。如果您提交它进行审核,它总是会给出 ou 的response.product 空。

No need to upload binary for Sandbox testing of InAppPurchase. You just have to add InAppPurchase item in iTunesConnect and put it in "Ready to submit"(must) state only. If you submit it for review it will always give ou response.product empty.

澜川若宁 2024-08-25 19:48:36

尝试添加免费订阅产品。如果它出现在响应中,那么您的代码没有任何问题。由于免费订阅是唯一不需要协议、税务和银行业务的类型,如果它出现而其他类型不需要,那么这就是与您的合同相关的问题。

Try to add a Free Subscription product. If it appears on the response then there is nothing wrong in your code. Since Free Subscription is the only type that doesn't require Agreements, Tax, and Banking and if it appears and the other types don't then it is a issue related to your contract.

ヤ经典坏疍 2024-08-25 19:48:36

就我而言,原因是苹果错误地打开了托管内容。该产品仅在我关闭时才可用

In my case the reason was hosting of content by Apple turned on by mistake. The product was available only when I turned it off

梦里南柯 2024-08-25 19:48:36

就我而言(MacOS),我正在创建一个测试应用程序(与主应用程序具有相同的捆绑包 ID)。仅当我将捆绑名称(二进制名称)设置为与原始应用程序中相同时,SKFetchRequest 才开始返回测试应用程序的产品 ID。

In my case (MacOS) I was creating a test application (with the same bundle ID of main application). SKFetchRequest started returning product Ids for test application only after I set Bundle Name (Binary name) the same as in original application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文