mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
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<JObject> 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);
|
|
}
|
|
}
|
|
}
|