【发布时间】:2015-02-12 07:54:11
【问题描述】:
我已经搜索了几天的 stackoverflow,以了解如何让产品从 iTunes Connect 中返回。我找到了很多信息,并试图遵循它。但是,我无法在 SKProductsResponse 中返回任何产品。
我正在使用 Xcode 6.1.1
我试过删除和重新添加产品。
我已经用模拟器和我的 iPhone 5 试过了。
我已经等了 24 小时,看看这是否会导致产品出现。没有。
这是我每次遵循的过程:
- 在 developer.apple.com 中:
- 检查我是否拥有有效的 iOS 开发证书
- 我的 iOS 设备 (iPhone 5) 已注册
- 创建一个新的应用程序 ID
- 使用显式应用 ID 和捆绑包 ID:com.ftotech.iaptest01
- 在应用服务中选中应用内购买复选标记
- 创建新的配置文件
- iOS 应用开发类型的配置文件
- 上面创建的选定应用 ID
- 选择了我的 iOS 开发证书
- 选择了我的 iOS 设备
- 将配置文件命名为与捆绑 ID 相同:com.ftotech.iaptest01
- 配置文件显示状态为 Active
- 创建具有以下分辨率的图标 PNG,没有 Alpha 通道:
- 1024x1024
- 76x76
- 120x102
- 152x152
- 创建具有以下分辨率的屏幕截图 PNG,没有 Alpha 通道:
- 3.5 英寸为 640x920
- 750x1334 为 4.7 英寸
- 4 英寸为 640x1096
- 5.5 英寸为 1242x2208
- 1024x748 适用于 iPad
- 640x920 用于产品
- 在 Xcode 中创建新的单视图项目:iaptest01
- 在项目设置、常规、身份部分:
- 已验证捆绑包 ID 为 com.ftotech.iaptest01
- 未找到签名身份错误,因此单击修复问题按钮,选择我的开发团队
- 错误消失了
- 在项目设置、常规、链接框架和库部分,添加了 StoreKit.framework
- 在项目设置的 Capabilities 部分中,验证应用内购买项目已打开,并检查两个步骤(链接 stoker.framework 和添加应用内购买权利)
- 向资产目录添加图标:
- 将 76x76 图标拖到 ipad app 1x
- 将 120x120 图标拖到 iphone 应用 2x
- 将 152x152 图标拖动到 ipad 应用 2x
- 在故事板中,添加了一个标签,在顶部居中,并添加了一个名为 labelProduct 的插座
- ViewController.h 下面
- ViewController.m 下面
- 存档应用并提交 - 成功
- 在项目设置、常规、身份部分:
- 在 iTunes Connect 中创建新的 iOS 应用
- 选定的捆绑包 ID com.ftotech.iaptest01
- 完整的定价部分
- 在应用内购买部分,创建一个消耗品
- 产品编号:com.ftotech.iaptest01.product1
- 已批准出售 - 是
- 设置语言设置
- 添加截图
- 产品展示状态为“准备提交”
- 在版本部分
- 填写所有必填字段
- 上传截图和图标
- 将产品添加到应用内购买部分
- 将构建添加到构建部分
- 已提交审核 - 已成功,正在等待审核
ViewController.m:
//
// ViewController.m
// iaptest01
//
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
activityIndicatorView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
activityIndicatorView.center = self.view.center;
[activityIndicatorView hidesWhenStopped];
[self.view addSubview:activityIndicatorView];
[activityIndicatorView startAnimating];
[self fetchAvailableProducts];
}
-(void)fetchAvailableProducts{
NSSet *productIdentifiers = [NSSet
setWithObjects:@"com.ftotech.iaptest01.product1",
nil];
productsRequest = [[SKProductsRequest alloc]
initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
}
-(void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *validProduct = nil;
int count = (int)[response.products count];
[_labelProduct setText:response.description];
if ( count > 0 ) {
validProducts = response.products;
validProduct = [response.products objectAtIndex:0];
[_labelProduct setText:[NSString stringWithFormat:
@"found product: %@",validProduct.localizedTitle]];
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:@"Available"
message:@"Found products"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Ok", nil];
[tmp show];
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:@"Not Available"
message:[@"No products: " stringByAppendingString:
[NSString stringWithFormat:@"%d", count]]
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Ok", nil];
[tmp show];
}
NSArray *products = response.invalidProductIdentifiers;
for (SKProduct *product in products)
{
NSLog(@"Product not found: %@", product);
}
[activityIndicatorView stopAnimating];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
ViewController.h:
//
// ViewController.h
// iaptest01
//
//
#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>
@interface ViewController : UIViewController<SKProductsRequestDelegate>
{
SKProductsRequest *productsRequest;
NSArray *validProducts;
UIActivityIndicatorView *activityIndicatorView;
}
@property (weak, nonatomic) IBOutlet UILabel *labelProduct;
- (void)fetchAvailableProducts;
@end
谁能看到我遗漏的步骤或我配置不正确的东西?
谢谢!
【问题讨论】:
-
this extremely thorough answer 有帮助吗?特别是,您似乎没有在任何时候提到创建测试用户,我猜这意味着您不会看到未经批准的产品?
-
测试用户似乎是为了进行(虚拟)购买。检索产品似乎不需要测试用户帐户。这是有道理的,因为您不必登录即可简单地获取产品列表。但是,感谢您提供该链接。我会搜索可能的答案。
-
在查看了 Matt Gibson 建议的链接后,我添加了一些代码来列出请求中的无效产品。这促使我再次查看我在 iTunes Connect 中的产品。该产品是“等待审查”,这似乎很奇怪。我点击产品,顶部有一条消息:“您目前没有有效的 iOS 付费应用合同。”我之前忽略了这一点。也许这就是问题所在。我已经完成了银行和税务信息,合同正在处理中。一旦完成,也许产品会出现?
标签: ios xcode6 app-store-connect