hellbound/Assets/Scripts/Managers/SDK.cs

87 lines
2.1 KiB
C#
Raw Normal View History

2021-11-26 11:16:25 +03:00
using System.Collections;
using RND.SDK;
#if RND_FACEBOOK
using Facebook.Unity;
#endif
#if RND_GAME_ANALYTICS
using GameAnalyticsSDK;
#endif
public class SDK : ILoading
{
public IEnumerator Load()
{
ProductStatistics.Init();
UserAcquisition.Init();
yield return null;
TryRequestIDFA();
InitFacebook();
}
private static void TryRequestIDFA()
{
#if UNITY_IOS
System.Version currentVersion;
var ios14dot5 = new System.Version("14.5");
try
{
currentVersion = new System.Version(UnityEngine.iOS.Device.systemVersion);
}
catch (System.Exception e)
{
Log.Warn(e);
currentVersion = new System.Version("1.0");
}
if (currentVersion > ios14dot5 &&
IDFATracking.IDFATracking.GetCurrentStatus() == IDFATracking.Status.NotDetermined)
{
IDFATracking.IDFATracking.RequestTracking((status) =>
{
Log.Info("SDK.TryRequestIDF: App Tracking Transparency Authorization Status: " + status);
});
}
else
{
Log.Info("SDK.TryRequestIDF: ATT is aprooved");
}
Log.Info($"SDK.TryRequestIDF: Current IDFA status: {IDFATracking.IDFATracking.GetCurrentStatus()}");
#endif
}
private static void InitFacebook()
{
#if RND_FACEBOOK
if (FB.IsInitialized)
{
FB.ActivateApp();
}
else
{
FB.Init(() =>
{
if (FB.IsInitialized)
FB.ActivateApp();
Log.Info(FB.IsInitialized
? "SDK.InitFacebook: Facebook init complete & app activated"
: "SDK.InitFacebook: Failed to Initialize the Facebook SDK");
}, (isGameShown) =>
{
UnityEngine.Time.timeScale = isGameShown ? 1 : 0;
Log.Info("SDK.Facebook: isGameShown: " + isGameShown);
});
}
#endif
}
public static void Reconnect()
{
UserAcquisition.Reconnect();
}
}