Skip to content

getGameSignatureWithGameID:completion: ​

Get Game Signature ​

This method requests the access signature (Game Signature) for a game from the SDK server via the specified gameID. This signature is a key credential for subsequent operations such as game download (preDownload), pre-load (preLoad), or start (startGame).


Method Declaration ​

objectivec
/**
 Request a game signature from the server using the specified game ID.
 @param gameID The unique identifier of the game.
 @param completion Called when the signature request finishes.
 */
+ (void)getGameSignatureWithGameID:(nonnull NSString *)gameID
                        completion:(nullable void(^)(NSString *_Nullable gameSignature, NSError *_Nullable error))completion;

+ (void)getGameSignatureWithGameID:(nonnull NSString *)gameID
                            language:(nullable NSString *)language
                          completion:(nullable void(^)(NSString *_Nullable gameSignature, NSError *_Nullable error))completion;

Parameters ​

ParameterTypeRequiredDescription
gameIDNSString *YesThe unique identifier of the game.
languageNSString *NoOptional language in the new overload, such as zh-CN. nil or an empty string uses the server default.
completionBlockNoCallback invoked after the signature is asynchronously retrieved. On success, returns the gameSignature string; on failure, returns error.

The original method remains available and is equivalent to passing language:nil. The language is sent as language to /v1/game/signature; the SDK does not substitute the system language for this request.

The result is still a gameSignature string. Its game metadata includes localized game_name and icon maps and the default game_icon URL. The SDK parses icon into SUDOPGameSignatureInfo.icon for the loading cover. Pass the original signature string to signature-based APIs; do not modify its metadata or log the signature.

Runtime Behavior ​

  1. Permission Validation: The SDK internally validates whether the user has been authenticated (authWithUserSignature:).
  2. Network Interaction: This interface initiates a network request to obtain the encrypted authorization credential for the game in the current environment.
  3. Result Reuse: The retrieved gameSignature usually has a certain validity period; it is recommended to use it immediately in the subsequent game loading flow.

Example Code ​

objectivec
NSString *targetGameID = @"game_123456";

[SUDOP getGameSignatureWithGameID:targetGameID language:@"zh-CN" completion:^(NSString * _Nullable gameSignature, NSError * _Nullable error) {
    if (error) {
        NSLog(@"Failed to get game signature: %@", error);
        return;
    }
    
    NSLog(@"Got game signature successfully");
    // You can now use gameSignature to call preDownloadGameWithSignature: or startGameWithSignature:
}];

Notes ​

  • Asynchronous Nature: Since this involves a network request, never block the main thread waiting for this callback.
  • Time Sensitivity: gameSignature is not permanently valid. If you do not perform a game operation for a long time after obtaining the signature, subsequent startGame may report that the signature has expired.
  • Error Code Handling: If error indicates no permission (e.g., the GameID does not belong to the AppID), check the game configuration in the console.