Crash callback handling (GUACrashObserver)
Set additional crash log data reporting
[MSDK & Player Network SDK] When the application crashes, you may need to report additional custom data together with the crash log to the CrashSight platform.This allows users to better identify the cause of the crash.Reported data can be found in the CrashSight platform under Trace Log > Attachment Information.For more information, see MSDK documentation.
The naming conventions for these files differ between Android and iOS.
note
It is strongly recommended that games register in the application startup function.
Function Definition
- Unity
- Unreal Engine
event OnStringRetEventHandler<GUABaseResult> CrashBaseRetEvents;
class GUA_EXTERN GUACrashObserver
{
public:
virtual ~GUACrashObserver(){};
// virtual long OnCrashExtraDataNotify(const GUACrashRet &crash_ret){
// return 0;
// };
virtual const char* OnCrashExtraMessageNotify(){
return NULL;
};
};
Code Example
- Unity
- Unreal Engine
// Initialization
UnionAdapterAPI.GetCrashService().SetCrashCallback();
// Add callback
UnionAdapterAPI.GetCrashService().CrashBaseRetEvents += OnCrashBaseResult;
// Remove callback
UnionAdapterAPI.GetCrashService().CrashBaseRetEvents -= OnCrashBaseResult;
// CrashBaseRetEvents callback handling
private string OnCrashBaseResult(GUABaseResult baseRet)
{
// this is not unity ui process, don't do anything about unity
return "this is Unity extra data when crash happened.";
}
// 1. Define an observer class in the engine layer that inherits from GUA_NAMESPACE::GUACrashObserver
// 2. Implement callback interfaces with the same method names (e.g., OnCrashExtraMessageNotify)
class FGUACrashObserver : public GUA_NAMESPACE::GUACrashObserver
{
public:
static FGUACrashObserver Instance;
public:
const char* OnCrashExtraMessageNotify()
{
char str[] = "this is extra message.";
char *retValue = SAFE_MALLOC(strlen(str) + 1, char);
strcpy(retValue, str);
return retValue;
}
};
FGUACrashObserver FGUACrashObserver::Instance;
// Set callback
GUA_NAMESPACE::GUACrashService::SetCrashObserver(&FGUACrashObserver::Instance);