using Newtonsoft.Json.Linq; using System; using System.Diagnostics; using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.Streams; using Windows.System.Profile; namespace CodePush.ReactNative { internal class CodePushUtils { internal async static Task GetJObjectFromFile(StorageFile file) { string jsonString = await FileIO.ReadTextAsync(file); if (jsonString.Length == 0) { return new JObject(); } try { return JObject.Parse(jsonString); } catch (Exception) { return null; } } internal static void Log(string message) { Debug.WriteLine("[CodePush] " + message, CodePushConstants.ReactNativeLogCategory); } internal static void LogBundleUrl(string path) { Log("Loading JS bundle from \"" + path + "\""); } internal static string GetDeviceId() { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer hardwareId = token.Id; var dataReader = DataReader.FromBuffer(hardwareId); var bytes = new byte[hardwareId.Length]; dataReader.ReadBytes(bytes); return BitConverter.ToString(bytes); } } }