GUAPushBaseResultObserver
[MSDK & Player Network SDK] Register the callback of the Push module, the game needs to process the callback function. For more information on the callback data structure, see GUABaseResult.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function Definition
- Unity
- Unreal Engine
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
PushBaseResultEvents | RegisterPush, UnregisterPush, SetTag, DeleteTag | - | AddLocalNotificationAtFront |
event OnResultHandler<GUABaseResult> PushBaseResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
PushBaseResultEvents | RegisterPush, UnregisterPush, SetTag, DeleteTag | - | AddLocalNotificationAtFront |
class GUA_EXTERN GUAPushObserver
{
public:
virtual ~GUAPushObserver() {};
virtual void OnPushOptNotify(const GUABaseResult &base_ret) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetPushService().PushBaseResultEvents += OnPushBaseResultEvent;
// Remove callbacks
UnionAdapterAPI.GetPushService().PushBaseResultEvents -= OnPushBaseResultEvent;
// 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 that inherits from GUA_NAMESPACE::GUAPushObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnPushOptNotify
class FGUAPushObserver : public GUA_NAMESPACE::GUAPushObserver {
public:
static FGUAPushObserver Instance;
void OnPushOptNotify(const GUA_NAMESPACE::GUABaseResult &base_ret)
{
}
};
FGUAPushObserver FGUAPushObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAPushService::SetPushObserver(&FGUAPushObserver::Instance);