Obtain the amount of the internal purchase item corresponding to the current region.
effect
If you need to display the amount and currency of the current region for in-game items, call this interface to obtain the amount and currency of the current region currency corresponding to the currently configured internal purchase item.
Function
objective-c
-(void)getLocalGoodsInfoV2:(void (^)(NSDictionary * _Nullable info, NSError * _Nullable error))callback;Correction
| Parameter name | Empty (Yes/No) | explain |
|---|---|---|
| info | Yes | info is a dictionary; its key is the price tier, and its value is the corresponding price information. For example: @{ @"0.99" : { @"amount" : @"8" , @"currency" : @"HKD",@"currencySymbol": @"HK$", @"formattedPrice" : @"HK$8" } } |
| error | Yes | Error message |
Key is the price tier
| Parameter name | Empty (Yes/No) | explain |
|---|---|---|
| {priceKey} | No | The price tier for the in-app purchase item, for example, 0.99. Its value is a dictionary containing the price information shown below. |
Value is the corresponding price information
| Parameter name | Empty (Yes/No) | explain |
|---|---|---|
| amount | No | The numeric amount from the store, without a currency symbol, currency code, thousands separators, or spaces. The decimal point is always . and insignificant trailing zeros are removed. |
| currency | No | The ISO 4217 currency code returned by the store, such as TWD, HKD, or USD. Use this field to identify the currency; do not infer it from symbols such as $. |
| currencySymbol | No | A common currency symbol obtained from the device Locale. It may be displayed as $, NT$, or TWD depending on the language, region, and system version, and is not guaranteed to exactly match the symbol in formattedPrice. |
| formattedPrice | No | The complete localized price ready to display, including the store-selected currency symbol, amount, decimal digits, grouping separators, and symbol position. Do not parse amount or currencySymbol from this field. |
Usage recommendations
- When displaying a price directly in the UI, use
formattedPricefirst. - When you need to arrange the amount and symbol yourself, use
amountandcurrencySymbol, but handle the symbol position and spacing yourself. Do not assume that the symbol always appears before the amount. - When identifying or recording the currency, use
currency. Do not determine the currency fromcurrencySymbol. - Do not use the outer price tier as the product ID.
- If the callback fails, using USD as a fallback is recommended.
Example code
objective-c
[[GamedreamerManager shareInstance] getLocalGoodsInfoV2:^(NSDictionary * _Nullable info, NSError * _Nullable error) {
if (error) {
NSLog(@"错误信息:%@",error);
} else {
NSLog(@"品项本地化价格信息:%@",info);
}
}];