getGameListWithOptions:completion:
Get Game List
The getGameListWithOptions method retrieves a paginated game list and returns pagination metadata and the current page of games through a callback.
To retrieve games in a specific selection, use getGameListWithSelectionId:options:completion:. The two methods use different server endpoints; the original method is unchanged.
For category queries, use getGameListWithCategoryOptions:completion: and getCategoryListWithOptions:completion:.
Prerequisite
Call initializeWithConfiguration:completion: and wait for the SDK to initialize successfully before calling this method.
Method Declaration
objectivec
+ (void)getGameListWithOptions:(nullable SUDOPGameListOptions *)options
completion:(nullable void(^)(SUDOPGameListResult *_Nullable result,
NSError *_Nullable error))completion;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| options | SUDOPGameListOptions * | No | Pagination and language options. Pass nil to request page 0 with 10 records per page and the server default language. |
| completion | Block | No | Called when the request finishes. On success, it returns result; on failure, it returns error. The callback runs on the main thread. |
SUDOPGameListOptions
| Field | Type | Default | Description |
|---|---|---|---|
| pageNo | NSInteger | 0 | Zero-based page number. Values below 0 are treated as 0. |
| pageSize | NSInteger | 10 | Number of records per page. Values less than or equal to 0 are treated as 10. |
| language | NSString * | nil | Language identifier, such as zh-CN. nil or an empty string uses the server default; the SDK does not substitute the system language. |
SUDOPGameListResult Result Model
| Field | Type | Description |
|---|---|---|
| pageNo | NSInteger | The zero-based page number returned by the server. |
| pageSize | NSInteger | The page size returned by the server. |
| total | NSInteger | Total number of games. |
| records | NSArray<SUDOPGameListItem *> * | Games on the current page. |
SUDOPGameListItem
| Field | Type | Description |
|---|---|---|
| gameId | NSString * | Game ID. |
| gameName | NSDictionary<NSString *, NSString *> * | Localized game names keyed by language tag. |
| gameIcon | NSString * | Default game icon URL. |
| icon | NSDictionary<NSString *, NSString *> * | Localized icon URLs keyed by language tag, with default for the default icon. May be nil when absent from the response. |
| version | NSString * | Game version. |
| gameIntroduction | NSDictionary<NSString *, NSString *> * | Localized game introductions keyed by language tag. May be nil when absent. |
| categoryInfo | SUDOPCategoryListItem * | Category metadata including its code, localized name, parent code, and level. May be nil when absent. |
Example
objectivec
SUDOPGameListOptions *options = [[SUDOPGameListOptions alloc] init];
options.pageNo = 0;
options.pageSize = 20;
options.language = @"zh-CN";
[SUDOP getGameListWithOptions:options
completion:^(SUDOPGameListResult * _Nullable result,
NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to get game list: %@", error.localizedDescription);
return;
}
NSLog(@"Page: %ld, total: %ld", (long)result.pageNo, (long)result.total);
for (SUDOPGameListItem *item in result.records) {
NSLog(@"Game ID: %@, version: %@", item.gameId, item.version);
}
}];Notes
- Page numbers are zero-based.
- This method performs a network request. Handle the result asynchronously in
completion. - When paging, use the returned
pageNo,pageSize, andtotalvalues to determine whether another page is available. - If
erroris returned, check the network and the games configured in the console.
