Skip to main content

PushBaseResultObserver

If you were looking for the method for use with Unreal Engine, see PushBaseResultObserver for Unreal Engine SDK.

Register the callback of the Player Network SDK Push module, the game needs to process the callback function. For more information on the callback data structure, see BaseResult.

note

It is strongly recommended to perform registration in the startup function of the game application.

Function definition

// Add the INTLBaseResult callback to process callback
public static void AddPushBaseResultObserver(OnINTLResultHandler<INTLBaseResult> callback);
// Remove the INTLBaseResult callback
public static void RemovePushBaseResultObserver(OnINTLResultHandler<INTLBaseResult> callback);

Code sample

// Add callbacks
public void AddPushObserver()
{
INTLAPI.AddPushBaseResultObserver(OnPushBaseRetEvent);
}

// Remove callbacks
public void RemovePushObserver()
{
INTLAPI.RemovePushBaseResultObserver(OnPushBaseRetEvent);
}

// Process the INTLBaseResult callback
public void OnPushBaseRetEvent(INTLBaseResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

if (ret.MethodId == (int)INTLMethodID.INTL_PUSH_REGISTER_PUSH)
{
methodTag = "RegisterPush";
}
else if (ret.MethodId == (int)INTLMethodID.INTL_PUSH_UNREGISTER_PUSH)
{
methodTag = "UnregisterPush";
}
else if (ret.MethodId == (int)INTLMethodID.INTL_PUSH_SET_TAG)
{
methodTag = "SetTag";
}
else if (ret.MethodId == (int)INTLMethodID.INTL_PUSH_DELETE_TAG)
{
methodTag = "DeleteTag";
}
ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(ret));
}