Skip to content

getGameListWithCategoryOptions:completion: ​

根据品类获取游戏列表 ​

POST /v1/game/getListByCategory

先成功调用 initializeWithConfiguration,再完成用户鉴权后请求数据。鉴权 Header、签名及加密由 SDK 处理,服务端需支持对应接口。

方法声明 ​

objectivec
+ (void)getGameListWithCategoryOptions:(nullable SUDOPGameListByCategoryOptions *)options
    completion:(nullable void(^)(SUDOPGameListResult *_Nullable result, NSError *_Nullable error))completion;

参数说明 ​

options 可传 nil。默认请求第 0 页、每页 10 条,语言使用服务端默认值。

品类 ID 位于继承 SUDOPGameListOptions 的 SUDOPGameListByCategoryOptions 中。

参数 / 字段类型描述
primaryCategoryIdNSString *一级品类 code,可选。
secondaryCategoryIdNSString *二级品类 code,填写时必须同时提供一级品类 code。
pageNoNSInteger从 0 开始,小于 0 时按 0 处理。
pageSizeNSInteger默认 10,小于或等于 0 时按 10 处理。
languageNSString *可选的 BCP 47 语言标签,如 zh-CN。nil 或空字符串使用服务端默认语言,SDK 不自动替换为系统语言。

品类 ID 使用 getCategoryListWithOptions 返回的 code。查询二级品类时,primaryCategoryId 使用该记录的 parentCode,secondaryCategoryId 使用其 code,不要转换为数字。两个 ID 均可不填;填写二级 ID 却未填写一级 ID 时,通过回调返回参数错误,不发送网络请求。

回调与返回结果 ​

成功返回 result,失败返回 error,completion 可传 nil。建议在主线程调用;本地参数校验失败可能在方法返回前直接触发回调。

复用 SUDOPGameListResult 和 SUDOPGameListItem。分页字段 pageNo、pageSize、total、records 以及游戏字段 gameId、gameName、gameIcon、icon、version 详见 getGameListWithOptions。

代码示例 ​

在初始化和鉴权成功后调用。示例品类编码需替换为实际值。

objectivec
SUDOPGameListByCategoryOptions *options = [[SUDOPGameListByCategoryOptions alloc] init];
options.pageNo = 0;
options.pageSize = 20;
options.language = @"zh-CN";
options.primaryCategoryId = @"123";
options.secondaryCategoryId = nil;

[SUDOP getGameListWithCategoryOptions:options completion:^(SUDOPGameListResult * _Nullable result, NSError * _Nullable error) {
    if (error) {
        NSLog(@"Request failed: %@", error.localizedDescription);
        return;
    }
    NSLog(@"page=%ld, total=%ld", (long)result.pageNo, (long)result.total);
}];

根据返回的 pageNo、pageSize 和 total 判断是否还有下一页。