Identity.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using UnityEngine;
  3. namespace TapSDK.Core.Standalone.Internal {
  4. public class Identity {
  5. public static readonly string DEVICE_ID_KEY = "tapdb_unique_id";
  6. public static readonly string PERSISTENT_ID_KEY = "tapdb_persist_id";
  7. public static readonly string INSTALLATION_ID_KEY = "tapdb_install_id";
  8. public static string DeviceId {
  9. get {
  10. string deviceId = TapCoreStandalone.Prefs.Get<string>(DEVICE_ID_KEY);
  11. if (string.IsNullOrWhiteSpace(deviceId)) {
  12. deviceId = SystemInfo.deviceUniqueIdentifier;
  13. TapCoreStandalone.Prefs.Set(DEVICE_ID_KEY, deviceId);
  14. }
  15. return deviceId;
  16. }
  17. }
  18. public static string PersistentId {
  19. get {
  20. string persistentId = TapCoreStandalone.Prefs.Get<string>(PERSISTENT_ID_KEY);
  21. if (string.IsNullOrWhiteSpace(persistentId)) {
  22. persistentId = Guid.NewGuid().ToString();
  23. TapCoreStandalone.Prefs.Set(PERSISTENT_ID_KEY, persistentId);
  24. }
  25. return persistentId;
  26. }
  27. }
  28. public static string InstallationId {
  29. get {
  30. string installationId = TapCoreStandalone.Prefs.Get<string>(INSTALLATION_ID_KEY);
  31. if (string.IsNullOrWhiteSpace(installationId)) {
  32. installationId = Guid.NewGuid().ToString();
  33. TapCoreStandalone.Prefs.Set(INSTALLATION_ID_KEY, installationId);
  34. }
  35. return installationId;
  36. }
  37. }
  38. }
  39. }