30

ユーザーの App Store の場所を知りたい。アメリカ、オーストラリア(AUD)のストアにあるということです。次のコードが使用されます。

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    Books = response.products;
    if ([SKPaymentQueue canMakePayments] && [response.products count]>0) {

    }

    for (SKProduct *book in Books) {
        NSLocale *locat=[NSLocale currentLocale];
        NSString *strlocate=[locat objectForKey:NSLocaleCountryCode];

        NSLog(@"\n\n\n Device country== %@ \n\n\n",strlocate);

        NSLocale* storeLocale = book.priceLocale;
        NSString *storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);
        NSLog(@"\n\n\n store country== %@ \n\n\n",storeCountry);
    }
}

アプリ ストアの価格マトリックス テーブルに基づいて、ブック レベルが 1 つである場合、US $ 0.99 AUD 0.99 JPY 85 を意味します。

シミュレーターでテストしました。システム内のiTunes、appstore、safariアプリの国名を変更しました。しかし、私は米国の国コードしか取得しません。

編集: 設定 -> 一般 -> 国際 -> 地域の形式 -> 国

デバイスでテストしました: デバイスの国のみが変更されました。ストアの国は、米国の国コードと価格を示しています。アプリ内購入開始前に国番号を保存したい。

通貨の変動に基づいて価格を変更するのは何日ですか? 既知/更新する変動価格のAPI/クエリを提供していますか?

私のinapp操作は1つのクラスを作りました。アプリ内操作を行う前に、ローカル価格をユーザーに表示したいのと同じ価格効果がアプリ内操作に反映されます。

サーバーから取得した無料の書籍と有料の書籍のリストを表示します。その中で、各アイテムの価格を表示します。これらのアイテムの価格は、アプリストアの処理中にドル価格で表示されます。アプリストアに価格が表示されている場合も、表示したいと思います。私のサーバーがその国に関連する価格表と通貨記号に応答する国コードをサーバーに送信したい..

4

9 に答える 9

32
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:prodcutIdentifier];
    productsRequest.delegate = self;
    
    // This will trigger the SKProductsRequestDelegate callbacks
    [productsRequest start];

これにより、デリゲート関数が呼び出されます。上記が完了すると、最終的に以下の関数が自動的に呼び出されます。ここで、送信されたアプリ ストア リクエストが確定されます。

(void)requestDidFinish:(SKRequest *)request
{
   
    
    SKProduct *book = [Books objectAtIndex:0];
        
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
    [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    [numberFormatter setLocale:book.priceLocale];
    
    NSLocale* storeLocale = book.priceLocale;
    NSString *storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);
    
}

あなたの興味に応じて、ロケールと国の詳細を提供してください。

于 2013-01-31T09:01:19.997 に答える
28

ここの本はSKProductです:

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:book.priceLocale];
NSString *formattedPrice = [numberFormatter stringFromNumber:book.price];

NSLog(@"%@", formattedPrice);

ご不明な点があればお尋ねください。

よろしく、

于 2013-01-25T10:11:46.577 に答える
6

私はこれを使用します:

  NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
    [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    [numberFormatter setLocale:basicProduct.priceLocale];
    NSString *formattedString = [numberFormatter stringFromNumber:basicProduct.price];
    NSLog(@"product with currency:%@", formattedString);
    [retDict setObject:formattedString forKey:@"basic_price"];
    NSLog(@"Product title: %@" , basicProduct.localizedTitle);
    NSLog(@"Product description: %@" , basicProduct.localizedDescription);
    NSLog(@"Product price: %@" , basicProduct.price);
    NSLog(@"Product id: %@" , basicProduct.productIdentifier);

デリゲートメソッドで:

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

これは、ユーザーがクリックして購入を開始する前に行うことができます..

于 2013-01-30T10:53:04.003 に答える
5

ロケールオブジェクトについて詳しく知ることができます。また、以下に示すように、NSLocaleによる通貨ロケールも使用できると思います。

 NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setLocale:[NSLocale currentLocale];
NSString *localizedMoneyString = [formatter stringFromNumber:myCurrencyNSNumberObject];

そして、あなたはこのような正しいフォーマットされた通貨文字列を得るでしょう、

SKProduct *product = [self.products objectAtIndex:indexPath.row];
NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setLocale:product.priceLocale];
currencyString = [formatter stringFromNumber:product.price];

そして私も私のアプリでこれを試しました

NSDecimalNumber *amount = [NSDecimalNumber decimalNumberWithString:@"50.00"];
NSNumberFormatter *currencyFormat = [[NSNumberFormatter alloc] init];
NSLocale *locale = [NSLocale currentLocale];
[currencyFormat setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormat setLocale:locale];
NSLog(@"Amount with symbol: %@", [currencyFormat stringFromNumber:amount]);//Eg: $50.00
NSLog(@"Current Locale : %@", [locale localeIdentifier]);//Eg: en_US

それがあなたを助けることを願っています

于 2013-01-30T10:07:38.227 に答える
3

productsResponse のデバイスで、AppStore アカウントの正しい product.price と product.priceLocale を受け取り、現在ログインしています。したがって、このロケールを使用して受け取った価格をフォーマットすると、「0.99$」、「33,0 руб」のような文字列が得られます。 ." 等々。

于 2013-01-22T08:31:16.310 に答える