Skip to main content

PushResultObserver

If you were looking for the method for use with Unreal Engine, see PushResultObserver 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 PushResult.

note

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

Function definition

// Add the INTLPushResult callback to process callback 
public static void AddPushResultObserver(OnINTLResultHandler<INTLPushResult> callback);
// Remove the INTLPushResult callback
public static void RemovePushResultObserver(OnINTLResultHandler<INTLPushResult> callback);

Code sample

// Add callbacks
public void AddPushObserver()
{
INTLAPI.AddPushResultObserver(OnPushNotificationEvent);
}

// Remove callbacks
public void RemovePushObserver()
{
INTLAPI.RemovePushResultObserver(OnPushNotificationEvent);
}

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

if (ret.MethodId == (int)INTLMethodID.INTL_PUSH_NOTIFICAITON_CALLBACK)
{
methodTag = "PushNotificationCallback";
}
ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(ret));
}