Skip to content

onGetLegacyUserIdentity ​

Get Original App User Identity ​

This method is used by a new version of the game package to obtain the original App user identity. Its main purpose: when a new version of the game starts, after the original App user logs in successfully, the game needs to obtain the original App user identity for subsequent game data synchronization.


Method Declaration ​

java
/**
 * Triggered when the SDK requests the legacy user identity (Legacy User Identity).
 * Usually used to maintain compatibility with older system versions or to migrate existing user data.
 *
 * @param handle   The state handle used to return the processing result to the SDK.
 */
void onGetLegacyUserIdentity(SUDOPStateHandle handle);

Runtime Behavior ​

  1. Trigger timing: When a mini game loads and attempts to restore the user's historical saves, records, or items, but finds that the current login system does not match the historical data, the engine initiates this request.
  2. Asynchronous feedback: After receiving the request, the App queries a local database or a server-side interface to find the corresponding legacy identity, and pushes it back asynchronously via handle.success(json).

Example Code ​

Implement the lookup and return logic for the legacy ID:

java
@Override
public void onGetLegacyUserIdentity(SUDOPStateHandle handle) {
    String userId = gameViewModel.getUserId();
    JSONObject obj = new JSONObject();
    try {
        obj.put("legacy_user_identity", userId);
    } catch (Exception e) {
        e.printStackTrace();
    }
    handle.success(obj.toString());
}

Notes ​

  • Compatibility guarantee: If your App is integrating the Sud SDK for the first time and has no legacy historical data, you can directly return handle.success("{}") or the current userId in this method.
  • Non-blocking call: Since identity lookup is involved, network latency may occur. You must respond asynchronously using the handle object; performing synchronous time-consuming operations inside the callback method is strictly forbidden.
  • Security: Only return the identifier required by the protocol. Do not pass through any plaintext passwords or sensitive private information in this interface.