Skip to content

onGetUserProfile:dataJson ​

Retrieve Sensitive User Info ​

This method is used to retrieve the original App user's sensitive info. Its main purpose is to provide sensitive App user info to the game.


Method Declaration ​

objectivec
/**
 * Triggered when the SDK requests sensitive user info (User Profile).
 * This typically involves more detailed fields than basic info, such as gender, region, and real-name status.
 *
 * @param stateHandle The state handle used to return the processing result to the SDK.
 * @param dataJson A JSON string containing request parameters (such as the user ID and the list of required detailed attributes).
 */
- (void)onGetUserProfile:(id<SUDOPStateHandle>)stateHandle dataJson:(NSString*)dataJson;

Runtime Behavior ​

  • On-demand trigger: When a player taps to view a detailed personal profile card in the game, or when the game needs to assign an initial character/skin based on gender or determine whether the player is a VIP, the engine initiates this request.
  • Precise field request: dataJson typically specifies the concrete userId and the list of fields the game is interested in (for example ["gender", "region", "vip_level"]).
  • Asynchronous assembly: Since detailed profile data may be distributed across different business systems (such as the membership system or geolocation service), the App can return it all at once via [stateHandle success:] after collecting all the data.
  • Privacy filtering: The App side can implement privacy logic within this method. For example, if the user has enabled "hide location," the App can choose not to return the region field or return desensitized data.

Code Example (Objective-C) ​

Implement on-demand assembly and return of detailed profile data:

objectivec
- (void)onGetUserProfile:(id<SUDOPStateHandle>)stateHandle dataJson:(NSString*)dataJson {

    NSDictionary *profile = @{
        @"gender": @"female",
        @"region": @"Beijing, China",
    };
    
    // 3. Convert the result to a JSON string
    NSData *resultData = [NSJSONSerialization dataWithJSONObject:profile options:0 error:nil];
    NSString *resultJson = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
    
    // 4. Return the success result asynchronously via stateHandle
    [stateHandle success:resultJson];
}

Notes ​

  • Field contract: In addition to the standard keys predefined by SUDOP, if the game has specific extended field requirements (such as combat power or guild name), make sure the JSON keys returned by the App side strictly match the names agreed upon by the game side.
  • Non-mandatory implementation: If your game only needs the avatar and nickname, this callback may never be triggered. However, for protocol completeness, it is recommended to call [stateHandle success:@"{}"] once even if no data is returned.
  • Error handling: If the user does not exist or data retrieval fails, you should call [stateHandle fail:SUDOP_ERR_UNKNOWN] (or the corresponding error code), to avoid the game side waiting indefinitely.