preLoadGameWithSignature:completion:
Pre-load Game (by Game Signature)
This method starts the pre-load flow using a pre-obtained game signature (Game Signature). It is one of the most commonly used pre-load methods, combining permission verification, resource download (if missing locally), and runtime environment initialization. Through the signature, the SDK can obtain all metadata of the game version, ensuring that the pre-loaded environment is fully consistent with the formal runtime environment.
Method Declaration
objectivec
/**
Pre-load game with a game signature to prepare the runtime environment.
@param gameSignature The signature used to authorize the game operation.
@param completion Called when the pre-load operation finishes.
@return An instance of id<SUDOPGameTask> to track the pre-load task.
*/
+ (nullable id<SUDOPGameTask>)preLoadGameWithSignature:(NSString *)gameSignature
completion:(nullable SUDOPGameOperationCompletionBlock)completion;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| gameSignature | NSString * | Yes | The game's authorization signature string, usually obtained via getGameSignatureWithGameID:completion:. |
| completion | SUDOPGameOperationCompletionBlock | No | Callback invoked after the asynchronous operation finishes. On success, returns the provider from which the handle can be obtained. |
Return Value
Returns an object conforming to id<SUDOPGameTask>. It may return nil if the task cannot be created.
Runtime Behavior
- Metadata Parsing: The SDK parses the signature to identify the game ID, version information, and resource verification identifier (FID).
- Silent Download (On Demand): If the game resource corresponding to the signature does not exist in the local cache, the SDK automatically starts the download flow.
- Environment Hot-start: Once resources are ready, the SDK initializes the runtime engine (Runtime), pre-loads the necessary scripts and configuration, and brings the game into a "ready-to-run" state.
- Handle Generation: When the
completioncallback fires, thegameHandlehas been preliminarily created and allocated, awaiting the finalstartGamecommand.
Example Code
objectivec
// 1. Obtain the signature
[SUDOP getGameSignatureWithGameID:@"game_123" completion:nil];Notes
- Signature Validity: Make sure the pre-load completes before the signature expires. If the signature expires during the pre-load, resource requests may fail.
- Resource Synchronization: This interface ensures that the specific version specified by the signature is loaded, effectively preventing inconsistency between the client version and the server configuration.
- Performance Optimization: At the UI level, you can call this interface when the user taps into the game detail page, thereby achieving instant entry when the user taps the "Start" button.
