如何在iOS中获取应用内购买的区域设置货币价格? [英] How to get locale currency price for in-app purchases in iOS?

查看:1345
本文介绍了如何在iOS中获取应用内购买的区域设置货币价格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找出用户的App Store位置。这意味着他们在美国,澳大利亚(澳大利亚)商店。使用以下代码。

I want to find out user's App Store location. It means they are in US, Australia(AUD) store. Following code used.

- (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);
    }
}

如果图书等级是一个,我想要明智$ 0.99 AUD 0.99 JPY 85基于应用商店价格矩阵表。

I want like wise if book tier is one means US $ 0.99 AUD 0.99 JPY 85 based on the app store price matrix table.

我在模拟器中测试过。我在系统中的iTunes,appstore和safari应用程序中更改了国家/地区名称。但我只获得美国国家代码。

I tested in the simulator. I changed country name in iTunes, appstore and safari application in the system. but I get only US country code.

编辑:
设置 - >常规 - >国际 - >地区格式 - >国家

Settings-> General-> International->Region Format-> country

我在设备中测试过:设备国家/地区仅更改。商店国家显示美国国家代码和价格。我想在开始购买时间之前存储国家/地区代码。

I tested in the device: Device country only changed. store country show US country code and price. I want to store country code before start inapp purchase time.

根据货币波动改变价格的天数?
它是否为已知/更新提供任何api /查询波动价格?

how many days once change the price for based on currency fluctuation? is it provide any api/ query for fluctuated price to known/update?

我的inapp操作是一个类。在进行inapp操作之前,我希望向用户显示当地价格,同样的价格效果反映在inapp操作中。

my inapp operation made one class. Before inapp operation made i want to display the local price to user same price effect reflect in the inapp operation.

我显示免费书籍和付费书籍列表从我的服务器获取。在那里我显示每个项目的价格。处理appstore时那些商品价格会显示美元价格。如果appstore显示价格,我也想显示。所以我想将国家代码发送到我的服务器,我的服务器响应该国家相关的价格表和货币符号..

i display the list of book free and paid books thats is list get from my server. in that i display the price for each item. those item price while processing the appstore it will show the dollar price. if appstore shown the price as also i want to shown. so that i want to send country code to my server from that my server respond that country related price list and currency symbol..

推荐答案

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

这将调用您的委托功能。完成上述操作后,它将最终自动调用下面提到的函数。这是发送的应用商店请求最终确定的位置。

This will call your delegate function. Once the above is done, it will automatically call the below mentioned function finally. This is where the app store request sent will be finalized.

(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);
    
}

根据您的兴趣提供区域设置和国家/地区详细信息。

provide the Locale and country details as per your interest.

这篇关于如何在iOS中获取应用内购买的区域设置货币价格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆