信息获取-拓展功能
更新时间:2026-05-27 06:05
# 1 功能介绍
该部分用于获取一些SDK的基础信息,根据具体使用场景选择调用即可
# 2 前置条件
调用接口前请确保已完成以下条件:
已经导入了USDK资源,并完成【第一步:集成】
iOS 版本为 11.0 及以上版本
# 3 接入步骤
# 3.1 获取设备号
接口声明
- (NSString *)getDeviceNum;
1
调用示例
[[UltraPlatform sharedInstance] getDeviceNum];
1
# 3.2 获取用户username
接口声明
- (NSString *)getUserName;
1
调用示例
[[UltraPlatform sharedInstance] getUserName];
1
# 3.3 获取用户userId
接口声明
- (NSString *)getUserId;
1
调用示例
[[UltraPlatform sharedInstance] getUserId];
1
# 3.4 获取sdk id
接口声明
- (NSString *)getSdkId;
1
调用示例
[[UltraPlatform sharedInstance] getSdkId];
1
# 3.5 获取渠道ID
适用版本 USDK v4.5.0以上
场景介绍
- 获取渠道ID,返回类型为字符串
接口声明
/**
@brief 获取渠道ID,必须在初始化后调用
*/
- (NSString *)getChannelId;
1
2
3
4
2
3
4
调用示例
NSString *channelId = [[UltraPlatform sharedInstance] getChannelId];
1
# 3.6 获取渠道名称
适用版本 USDK v4.5.0以上
场景介绍
- 获取渠道名称,返回类型为字符串
接口声明
/**
@brief 获取渠道名称,必须在初始化后调用
*/
- (NSString *)getChannelName;
1
2
3
4
2
3
4
调用示例
NSString *channelName = [[UltraPlatform sharedInstance] getChannelName];
1
# 3.7 获取Apple商品详情
适用版本 USDK v5.5.8及其以上版本,全球渠道v4.8.1及其以上版本
场景介绍
- 获取苹果后台商品id对应的商品在不同地区(根据当前用户登录的苹果账号)的详细信息,比如币种 、价格 等
接口声明
- (void)getAppleSkuDetailsList:(NSArray<NSString *> *)gameGoodsList
success:(void (^)(NSArray<NSString *> *))success
failure:(void (^)(NSString *error))failure;
1
2
3
2
3
调用示例
// 传入参数为数组类型,游戏对应的goodsId
NSArray* gameGoodsList = @[@"61", @"1000", @"10000", @"63", @"50", @"124"];
[[UltraPlatform sharedInstance] getAppleSkuDetailsList:gameGoodsList success:^(NSArray *result) {
/**
[{
"amount = "8990",
"appleGoodsId = "com.global.648",
"currency = "RUB",
"gameGoodsId = "50",
"price = "8 990,00 ₽",
}]
*/
NSLog(@"获取苹果商品信息成功 = %@", result);
// 回调数据为一个数组,数组个数一定是大于0的,否则会走失败回调,可以遍历数组,取到对应的信息
for (NSDictionary* info in result) {
NSString* appleGoodsId = info[@"appleGoodsId"];
NSString* gameGoodsId = info[@"gameGoodsId"];
NSString* price = info[@"price"];
NSString* amount = info[@"amount"];
NSString* currency = info[@"currency"];
}
} failure:^(NSString *error) {
NSLog(@"获取苹果商品信息失败 = %@", error);
}];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
回调字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| gameGoodsId | NSString | 游戏商品id |
| appleGoodsId | NSString | 苹果后台商品id |
| price | NSString | 当地商品的格式化价格,包括其货币符号。比如 "$99.99","HK$148.00","¥3,000","8 990,00 ₽" |
| currency | NSString | 当前苹果账号所在地区的价格的 ISO 4217 货币代码。 比如俄罗斯卢布 RUB 、 美元 USD |
| amount | NSString | 单位为苹果开发者后台配置商品ID的单位,如USD为美元,CNY为元 |
本文档对解决你的问题有所帮助?
