iPhone In App Purchase - response.products仍然是空的? [英] iPhone In App Purchase - response.products are still empty?

查看:191
本文介绍了iPhone In App Purchase - response.products仍然是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我已经尝试在测试应用中设置应用内购买,然后再将其应用到我公司正在开发的应用中。我已经阅读了商店套件pdf和其他片段大约1000次,但产品仍然是空的。以下是我到目前为止所做的事情:

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:

设置测试应用和In App Purchase测试项目

我创建了我公司在iPhone开发人员中心的开发人员门户网站上的Test App One的新应用程序ID。我确保前缀为 com.mycompany.testappone ,以确保可以配置应用内购买。保持应用程序ID部分,我通过勾选启用应用程序内购买选项配置应用程序购买。

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.

我在iTunes Connect中创建了Test App One并完成了通常的程序,但选择'稍后上传二进制',并没有提交审查,因为该应用程序什么都不做。当然,我们不必提交应用程序来审查这个工作?!然后,我点击管理应用内购买并创建了一个新产品ID为'test1'并批准它以便将其清除出售。

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.

代码

我在XCode中设置了一个名为 TestAppOne 的新项目,这里是我现在使用的唯一两个类:

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:

TestAppOneAppDelegate.h:

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

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

TestAppOneDelegate.m:

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

测试设备

我创建了一个沙箱测试帐户,并在iPhone上注销了我的iTunes帐户,但没有使用测试帐户登录,因为文档告诉我们不要这样做直到我们在购买阶段被提示。然后我构建应用程序,这是我得到的日志:

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

任何人都可以告诉我,如果我已经离开了任何阶段,或者是否有任何我做错了。不幸的是,Apple似乎没有任何示例应用程序。

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.

推荐答案

实际上我认为你必须提交二进制文件为了这个工作。

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

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

You can set the release date to the distant future.

这篇关于iPhone In App Purchase - response.products仍然是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆