2

私のプロジェクトでアプリ内購入を使用しています.現在、サンドボックスからの購入が機能しています.しかし、製品識別子に関する1つの問題が見つかりました.今、私は以下のように製品識別子をハードコーディングしています. 製品識別子を 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 からのコード

ProductId.PLIST

問題は、iTunes Store から製品 ID を動的に取得できないことです。では、plist でハードコーディングする代わりに、iTunes ストアから製品 ID を取得するにはどうすればよいでしょうか? 助けてください

4

3 に答える 3

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
于 2013-07-30T17:04:05.543 に答える
2

AppStore からこれらの識別子を取得することはできません!. これらの製品 ID を動的に配信する必要がある場合は、ID のリストを含むファイルを可視サーバーに配置する必要があります。

Apple ドキュメントの「機能の提供」セクションをお読みください。「サーバー製品モデル」を使用する必要があります。

iOS 7 以降の編集:

私が書いた古いリンクは古くなっています。現在のドキュメントはより明示的です

于 2013-07-26T04:11:57.197 に答える
0

アプリ内の AppStore から製品 ID を取得することはできませんが、製品 ID の plist を自動的に生成できます。

手順は次のとおりです。

  1. transportermetadata.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>'
    

これらのシェル スクリプトを本番デプロイ スクリプトに統合することも、この概念に基づいて独自のスクリプトを作成することもできます。

于 2014-09-22T10:13:22.483 に答える