在购买应用程序时无法从iTunes Connect获取产品标识符?

时间:2013-07-26 03:22:47

标签: ios objective-c in-app-purchase plist itunesconnect

iam在我的项目中使用In App购买。目前正在购买的东西正在从沙盒发生。但是我发现了一个关于产品标识符的问题。现在我很难对产品标识符进行硬编码,如下所示。我手动将产品标识符存储在plist(ProductId.plist)中(请参考图片)

#import "RageIAPHelper.h"

@implementation RageIAPHelper

+ (RageIAPHelper *)sharedInstance {
    static dispatch_once_t once;
    static RageIAPHelper * sharedInstance;
    dispatch_once(&once, ^{
        NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"ProductId" ofType:@"plist"];

        NSArray * contentArray = [NSArray arrayWithContentsOfFile:plistPath];
        NSLog(@"content aray:%@",contentArray);
        NSSet * productIdentifiers= [NSSet setWithArray:contentArray];
        sharedInstance = [[self alloc] initWithProductIdentifiers:productIdentifiers];
    });
    return sharedInstance;
}

@end  

//应用程序购买TALLTOR的RAY WENDERLICH代码

ProductId.PLIST

现在问题是无法从iTunes Store动态获取产品标识符。那么我怎样才能从itunes商店获得产品ID而不是plist中的硬编码? 请帮忙

3 个答案:

答案 0 :(得分:2)

您无法从AppStore获取这些标识符!如果您确实需要动态提供这些产品标识符,则应将带有标识符列表的文件放在可见的服务器中。

请阅读Feature Delivery in Apple documentation部分。您应该使用“服务器产品型号”。

编辑后iOS 7:

我写的旧链接已过时。 The current doc is more explicit

答案 1 :(得分:2)

您可以执行以下操作来获取产品数据。

 NSSet *productIdentifiers = [NSSet setWithObject:@"com.****.******"];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];

此代表将致电,获取您所需的产品信息

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

答案 2 :(得分:0)

您无法从AppStore IN APP获取产品ID, 但是你可以自动生成产品ID。

以下步骤:

  1. 使用transporter

    获取metadata.xml
    iTMSTransporter -m lookupMetadata \
    -u [username] \
    -p [password] \
    -vendor_id [vendor id] \
    -subitemtype InAppPurchase \
    -destination [local destination]
    
  2. metadata.xml转换为product_ids.plist

    # /usr/bin/sh
    # usage: [this script] [path/to/metadata.xml] > [path/to/product_ids.plist]
    
    echo '<?xml version="1.0" encoding="UTF-8"?>'
    echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"'
    echo ' "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
    echo '<plist version="1.0">'
    echo '<array>'
    
    sed -n 's/.*<product_id>\(.*\)<.*/    \<string\>\1\<\/string\>/p' $1
    
    echo '</array>'
    echo '</plist>'
    
  3. 您可以将这些shell脚本集成到生产部署脚本中,或者您可以根据此概念编写自己的脚本。