Create a static method with the [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] attribute and activate AppMetrica using the AppMetrica.Activate() method.
Example:
using Io.AppMetrica;
using UnityEngine;
publicstaticclassAppMetricaActivator {
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
privatestaticvoidActivate() {
AppMetrica.Activate(new AppMetricaConfig("APIKey") {
FirstActivationAsUpdate = !IsFirstLaunch(),
});
}
privatestaticboolIsFirstLaunch() {
// Implement logic to detect whether the app is opening for the first time.// For example, you can check for files (settings, databases, and so on),// which the app creates on its first launch.returntrue;
}
}
If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.