Created
December 14, 2020 07:30
-
-
Save gmYusuf/c01ad57a46dc0bee9af84ed9fb37cb27 to your computer and use it in GitHub Desktop.
CrashManager using Huawei sdk functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HuaweiMobileServices.Crash; | |
using UnityEngine; | |
public class CrashManager : MonoBehaviour | |
{ | |
IAGConnectCrash agConnectCrash; | |
void Start() | |
{ | |
Debug.Log("[HMS]: Crash Initialized"); | |
agConnectCrash = AGConnectCrash.GetInstance(); | |
} | |
public void enableCrashCollection(bool value) | |
{ | |
agConnectCrash.EnableCrashCollection(value); | |
Debug.Log($"[HMS]: Crash enableCrashCollection {value}"); | |
} | |
public void testIt() | |
{ | |
Debug.Log("[HMS]: Crash testIt"); | |
Application.ForceCrash(0); | |
} | |
enum Log | |
{ | |
DEBUG=3, | |
INFO=4, | |
WARN=5, | |
ERROR=6, | |
} | |
public void customReport() | |
{ | |
agConnectCrash.SetUserId("testuser"); | |
agConnectCrash.Log((int) Log.DEBUG, "set debug log."); | |
agConnectCrash.Log((int) Log.INFO, "set info log."); | |
agConnectCrash.Log((int) Log.WARN, "set warning log."); | |
agConnectCrash.Log((int) Log.ERROR, "set error log."); | |
agConnectCrash.SetCustomKey("stringKey", "Hello world"); | |
agConnectCrash.SetCustomKey("booleanKey", false); | |
agConnectCrash.SetCustomKey("doubleKey", 1.1); | |
agConnectCrash.SetCustomKey("floatKey", 1.1f); | |
agConnectCrash.SetCustomKey("intKey", 0); | |
agConnectCrash.SetCustomKey("longKey", 11L); | |
Debug.Log("[HMS]: Crash customReport"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment