NativeAppInfo.cs 674 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Runtime.InteropServices;
  3. internal static class NativeAppInfo
  4. {
  5. #if UNITY_IOS && !UNITY_EDITOR
  6. [DllImport("__Internal")]
  7. private static extern IntPtr AppRuntimes_GetTestUserID();
  8. [DllImport("__Internal")]
  9. private static extern void AppRuntimes_FreeString(IntPtr value);
  10. #endif
  11. internal static string GetTestUrl()
  12. {
  13. #if UNITY_IOS && !UNITY_EDITOR
  14. var value = AppRuntimes_GetTestUserID();
  15. if (value == IntPtr.Zero) return string.Empty;
  16. try { return Marshal.PtrToStringAnsi(value) ?? string.Empty; }
  17. finally { AppRuntimes_FreeString(value); }
  18. #else
  19. return string.Empty;
  20. #endif
  21. }
  22. }