GUAIDTokenResultObservers [Player Network SDK only]
Register the callback for the login module, the game needs to handle the callback.For more information on the callback data structure, refer to the following data structure GUAIDTokenResult.
note
[MSDK Only] It is strongly recommended that the game registers the callback in the application’s startup function.
Data structure
GUAIDTokenResult: Inherits from GUABaseResult.
| Parameters | Type | Description |
|---|---|---|
| IdToken | string | Player Network SDK Unique OpenID Defaults to a string representing a 64-bit unsigned integer, but 32-bit is also supported. |
Function Definition
- Unity
- Unreal Engine
// IDTokenEvents callback event, used to handle the callback of QueryIDToken
event OnResultHandler<GUAIDTokenResult> IDTokenEvents;
// OnIDTokenResultNotify callback event, used to handle the callback of QueryIDToken
class GUA_EXTERN GUAAccountObserver
{
public:
virtual ~GUAAccountObserver() {};
virtual void OnIDTokenResultNotify(const GUAIDTokenResult &id_result) {};
};
Code Example
- Unity
- Unreal Engine
// Add callback
UnionAdapterAPI.GetAccountService().IDTokenEvents += OnIDTokenEvent;
// Remove callback
UnionAdapterAPI.GetAccountService().IDTokenEvents -= OnIDTokenEvent;
// Callback handler for IDTokenEvents
public void OnIDTokenEvent(GUAIDTokenResult idtokenret)
{
Debug.Log("OnIDTokenEvent in Auth");
}
// 1. Define an observer class in the engine layer that inherits from GUA_NAMESPACE::GUAAccountObserver
// 2. Implement callback interfaces with the same method names (e.g., OnIDTokenResultNotify)
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnIDTokenResultNotify(const GUA_NAMESPACE::GUAIDTokenResult &id_result)
{
}
};
FGUAAccountObserver FGUAAccountObserver::Instance;
// Set the callback
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);