preDownloadGameWithSignature:completion:
Pre-download Game (by Game Signature)
This method starts an asynchronous game package download task using a pre-obtained game signature (Game Signature). Compared with using the Game ID directly, this interface is suitable for cases where the developer has already exchanged for a signature on the server or in another step. It skips the internal step of requesting the signature again, allowing the download flow to start faster.
Method Declaration
objectivec
/**
Pre-download game package using a game signature.
@param gameSignature The signature used to authorize the game download.
@param completion Called when the download task finishes or fails.
@return An instance of id<SUDOPGameTask> to control or track the task.
*/
+ (nullable id<SUDOPGameTask>)preDownloadGameWithSignature:(nonnull NSString *)gameSignature
completion:(nullable SUDOPCompletionBlock)completion;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| gameSignature | NSString * | Yes | The game's authorization signature string. |
| completion | SUDOPCompletionBlock | No | Task-finished callback. On success, error is nil; on failure, error contains the specific reason. |
Return Value
Returns an object conforming to id<SUDOPGameTask>. It may return nil if the task cannot be created.
Runtime Behavior
- Direct Authorization: The SDK parses the permission information in the signature and directly establishes the download channel.
- File Verification: During the download, the package integrity is verified in real time based on the metadata contained in the signature (such as FID).
- Cache Reuse: If a game package of the version corresponding to this signature already exists locally and passes verification, the task directly triggers the completion callback (progress jumps to 100%).
Example Code
objc
// Assume the signature has been obtained via getGameSignatureWithGameID
NSString *signature = @"your_game_signature_string";
[SUDOP preDownloadGameWithSignature:signature completion:nil];Notes
- Validity Check: If the passed
gameSignatureis expired or malformed, the task immediately returns an error viacompletion, and the error code is usually related to authentication failure. - Version Locking: A signature is usually bound to a specific game version. If you need to update the game, make sure to obtain the latest signature before calling this interface.
- Concurrency Limit: At the same time, the SDK may merge downloads of the same resource to avoid redundant bandwidth usage.
