Skip to content

Get Voice Configuration ​

Description ​

This API applies only to games that support multiple voice-over tracks. It obtains the corresponding voice configuration based on the current IP address. Games without this requirement do not need to integrate this API.


Function ​

objective-c
- (void)gamedreamerGetVoiceConfigWithCompletion:(void (^)(NSString * _Nullable regionCode,
                                                          NSString * _Nullable voiceLanguage,
                                                          NSError * _Nullable error))completion;

Parameters ​

ParameterNullable (Yes/No)Description
regionCodeYesReturns the region code corresponding to the current IP address on success; returns nil on failure.
voiceLanguageYesReturns the voice-over language identifier on success. Compare it with VoiceLanguageCantonese or VoiceLanguageMandarin for validation; returns nil on failure.
errorYesReturns the error information; returns nil on success.

Usage Recommendations ​

  • Call this API after a successful login. If login has not yet been completed, the SDK shows a prompt and does not trigger the completion callback.
  • If the configuration fails to be retrieved, the caller is recommended to retry. If the retry also fails, use the default voice-over.
  • To support additional voice-over languages, contact technical support for confirmation first.
  • After the voice configuration is successfully obtained, the caller should cache the result. There is no need to call this API repeatedly.

Sample Code ​

objective-c
[GamedreamerManager.shareInstance gamedreamerGetVoiceConfigWithCompletion:^(NSString * _Nullable regionCode, NSString * _Nullable voiceLanguage, NSError * _Nullable error) {
    if (error) {
        NSLog(@"---Failed to get voice configuration: %@---", error);
        return;
    }

    if ([voiceLanguage isEqualToString:VoiceLanguageCantonese]) {
        NSLog(@"---Use Cantonese---");
    } else if ([voiceLanguage isEqualToString:VoiceLanguageMandarin]) {
        NSLog(@"---Use Mandarin---");
    } else {
        NSLog(@"---Contact technical support to support other voice-over languages---");
    }
}];