Skip to content

getGameInformationWithGameID:language:completion: ​

获取游戏信息 ​

getGameInformationWithGameID 方法用于获取指定游戏的详细信息。可以传入 BCP 47 语言标签,也可以使用不含 language 参数的重载方法。


调用前置条件 ​

调用该方法前,必须先调用 initializeWithConfiguration:completion: 并确保 SDK 初始化成功。


方法声明 ​

objectivec
+ (void)getGameInformationWithGameID:(nonnull NSString *)gameID
                            language:(nonnull NSString *)language
                          completion:(nullable void(^)(SUDOPGameInformation *_Nullable gameInformation,
                                                       NSError *_Nullable error))completion;

+ (void)getGameInformationWithGameID:(nonnull NSString *)gameID
                          completion:(nullable void(^)(SUDOPGameInformation *_Nullable gameInformation,
                                                       NSError *_Nullable error))completion;

不需要指定语言时,可使用不含 language 参数的重载方法。SDK 将优先使用系统首选语言;系统首选语言不可用时使用 en。


参数说明 ​

参数名类型必传描述
gameIDNSString *是游戏的唯一标识符,不可为 nil。
languageNSString *是BCP 47 语言标签,例如 zh-CN、en-US。不需要指定语言时,可使用不含此参数的重载方法。
completionBlock否请求完成后的回调。成功时返回 gameInformation;失败时返回 error。回调在主线程执行。

返回模型 SUDOPGameInformation ​

字段类型描述
gameIDNSString *游戏 ID。
gameNameNSDictionary<NSString *, NSString *> *游戏名(多语言)。
gameIconNSString *游戏图标 URL。
iconNSDictionary<NSString *, NSString *> *游戏图标 URL(多语言)。
gameIntroductionNSDictionary<NSString *, NSString *> *游戏简介(多语言)。
gameDescriptionNSDictionary<NSString *, NSString *> *游戏详情(多语言)。
categoryNSInteger游戏分类:1-角色扮演,2-经营策略,3-休闲益智,4-动作冒险,5-射击游戏,6-体育竞速,7-棋牌游戏,8-音乐舞蹈。
servicePhoneNSString *客服电话。
serviceEmailNSString *客服邮箱。
subjectTypeNSInteger认证类型:0-个人,1-企业。
subjectNameNSString *认证主体:企业全称或个人姓名。
privacyPolicyUrlNSString *隐私政策 URL。
privacyPolicyNSDictionary<NSString *, NSString *> *隐私政策 URL(多语言)。
packageMd5NSString *游戏包的 MD5 校验值。
versionNSString *游戏版本号。
updateTimelong long更新时间戳,单位为毫秒。

多语言字典至少包含一个 default key,其 value 为默认值。其他 key 为 BCP 47 语言标签,value 为对应语言的内容。所需语言不存在时,可读取 default 对应的值。


代码示例 ​

objectivec
NSString *gameID = @"game_101";
NSString *language = @"zh-CN";

[SUDOP getGameInformationWithGameID:gameID
                           language:language
                         completion:^(SUDOPGameInformation * _Nullable gameInformation,
                                      NSError * _Nullable error) {
    if (error) {
        NSLog(@"获取游戏信息失败: %@", error.localizedDescription);
        return;
    }

    NSString *gameName = gameInformation.gameName[language]
        ?: gameInformation.gameName[@"default"];
    NSLog(@"游戏名: %@", gameName);
}];

// 不指定语言,使用系统首选语言
[SUDOP getGameInformationWithGameID:gameID completion:nil];

注意事项 ​

  • gameID 为必传参数,请勿传入 nil 或空字符串。
  • 该方法会发起网络请求,请通过 completion 异步处理结果。
  • 指定 language 时应传入有效的 BCP 47 语言标签。
  • 返回 error 时,请检查网络状态、游戏 ID 以及控制台中的游戏配置。