【问题标题】:Not able to get product Identifiers from iTunes Connect in app purchase?无法在应用购买中从 iTunes Connect 获取产品标识符?
【发布时间】:2013-07-26 03:22:47
【问题描述】:

我在我的项目中使用应用内购买。目前正在从沙盒进行购买。但我发现了一个关于产品标识符的问题。现在我正在对产品标识符进行硬编码,如下所示。我手动将产品标识符存储在 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  

//应用购买教程中来自 RAY WENDERLICH 的代码

问题是现在无法从 iTunes Store 动态获取产品标识符。那么如何从 iTunes 商店获取产品 ID 而不是在 plist 中进行硬编码??? 请帮忙

【问题讨论】:

    标签: ios objective-c in-app-purchase plist app-store-connect


    【解决方案1】:

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

     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
    

    【讨论】:

    • 此方法仅适用于获取现有产品ID的信息,不适用于从iTunes连接中获取产品ID。
    【解决方案2】:

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

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

    在 iOS 7 之后编辑:

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

    【讨论】:

      【解决方案3】:

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

      步骤如下:

      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>'
        

      您可以将这些 shell 脚本集成到您的生产部署脚本中,也可以基于此概念编写自己的脚本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-05
        • 1970-01-01
        • 2017-03-20
        • 1970-01-01
        相关资源
        最近更新 更多