Skip to main content

Push module callback (GUAPushResultObserver)

[MSDK & Player Network SDK] Register the callback for the Push module. The game needs to register the callback for processing.For more about the callback data structure, see GUABaseResult.

note

It is strongly recommended that games register in the application startup function.

Function Definition

Method list for handling callback events

Callback eventCommon[Player Network SDK only][MSD only]
PushNotificationEventsAddLocalNotification,
ClearLocalNotification
*-
event OnResultHandler<GUAPushResult> PushNotificationEvents;

Code Example

// Add callback
UnionAdapterAPI.GetPushService().PushNotificationEvents += OnPushNotificationEvent;
// Remove callback
UnionAdapterAPI.GetPushService().PushNotificationEvents -= OnPushNotificationEvent;

// Callback handling for PushNotificationEvents
private void OnPushNotificationEvent(GUAPushResult pushResult)
{
string methodTag = "";
if (pushResult.MethodId == (int)GUAMethodID.GUA_PUSH_ADD_LOCAL_NOTIFICATION)
{
methodTag = "AddLocalNotification";
}
else if (pushResult.MethodId == (int)GUAMethodID.GUA_PUSH_CLEAR_LOCAL_NOTIFICATIONS)
{
methodTag = "ClearLocalNotification";
}
else if (pushResult.MethodId == (int)GUAMethodID.GUA_PUSH_NOTIFICATION_CALLBACK)
{
methodTag = "NotificationCallback";
}
Debug.Log(methodTag + pushResult.ToString());
}