QDAppStoreManagerInit.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using UniFramework.Event;
  3. namespace GFGGame.Launcher
  4. {
  5. public static class QDAppStoreManagerInit
  6. {
  7. public static int AppTrackingAuthorizationStatus;
  8. private const string ATTStatusLocalKey = "ATTStatusLocalKey";
  9. public static void InitPlatform()
  10. {
  11. #if !UNITY_EDITOR && UNITY_IOS
  12. AppTrackingAuthorizationStatus = ATTAuth.GetAppTrackingAuthorizationStatus();
  13. if (AppTrackingAuthorizationStatus == 0)
  14. {
  15. bool requested = LocalCache.GetBool(ATTStatusLocalKey, false);
  16. if(!requested)
  17. {
  18. AddIOSMethod();
  19. ATTAuth.RequestTrackingAuthorizationWithCompletionHandler((status) =>
  20. {
  21. Debug.Log("ATT status :" + status);
  22. AppTrackingAuthorizationStatus = status;
  23. });
  24. }
  25. }
  26. #endif
  27. UniEvent.SendMessage(new LauncherEvent.InitPlatformResult() { success = true});
  28. }
  29. private static void AddIOSMethod()
  30. {
  31. string objName = "IOSMethod";
  32. var obj = GameObject.Find(objName);
  33. if(obj == null)
  34. {
  35. obj = new GameObject(objName);
  36. GameObject.DontDestroyOnLoad(obj);
  37. }
  38. obj.AddComponent<ATTAuth>();
  39. }
  40. }
  41. }