Callback for the Push module (GUAPushBaseResultObserver)
[MSDK & Player Network SDK] Register the callback for the Push module. The game needs to register the callback to process events.For more details on the callback data structure, see GUABaseResult.
note
It is strongly recommended that games register in the application startup function.
Function Definition
- Unity
- Unreal Engine
List of methods for handling callback events
| Callback event | Common | [Player Network SDK only] | [MSD only] |
|---|---|---|---|
| PushBaseResultEvents | RegisterPush, UnregisterPush, SetTag, DeleteTag | * | AddLocalNotificationAtFront |
event OnResultHandler<GUABaseResult> PushBaseResultEvents;
List of methods for handling callback events
| Callback event | Common | [Player Network SDK only] | [MSD only] |
|---|---|---|---|
| PushBaseResultEvents | RegisterPush, UnregisterPush, SetTag, DeleteTag | * | AddLocalNotificationAtFront |
class GUA_EXTERN GUAPushObserver
{
public:
virtual ~GUAPushObserver() {};
virtual void OnPushOptNotify(const GUABaseResult &base_ret) {};
};
Code Example
- Unity
- Unreal Engine
// Add callback
UnionAdapterAPI.GetPushService().PushBaseResultEvents += OnPushBaseResultEvent;
// Remove callback
UnionAdapterAPI.GetPushService().PushBaseResultEvents -= OnPushBaseResultEvent;
// Handling of PushBaseResultEvents callback
private void OnPushBaseResultEvent(GUABaseResult ret)
{
string methodTag = "";
if (ret.MethodId == (int)GUAMethodID.GUA_PUSH_REGISTER)
{
methodTag = "RegisterPush";
}
else if (ret.MethodId == (int)GUAMethodID.GUA_PUSH_UNREGISTER)
{
methodTag = "UnregisterPush";
}
else if (ret.MethodId == (int)GUAMethodID.GUA_PUSH_SET_TAG)
{
methodTag = "SetTag";
}
else if (ret.MethodId == (int)GUAMethodID.GUA_PUSH_DELETE_TAG)
{
methodTag = "DeleteTag";
}
Debug.Log(methodTag + ret.ToString());
}
// 1. Define an observer class in the engine layer that inherits from GUA_NAMESPACE::GUAPushObserver
// 2. Implement callback interfaces with the same method names (e.g., OnPushOptNotify)
class FGUAPushObserver : public GUA_NAMESPACE::GUAPushObserver {
public:
static FGUAPushObserver Instance;
void OnPushOptNotify(const GUA_NAMESPACE::GUABaseResult &base_ret)
{
}
};
FGUAPushObserver FGUAPushObserver::Instance;
// Set callback
GUA_NAMESPACE::GUAPushService::SetPushObserver(&FGUAPushObserver::Instance);