forked from microsoft/react-native-code-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodePushUtils.cs
More file actions
53 lines (46 loc) · 1.43 KB
/
CodePushUtils.cs
File metadata and controls
53 lines (46 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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> GetJObjectFromFileAsync(StorageFile file)
{
string jsonString = await FileIO.ReadTextAsync(file).AsTask().ConfigureAwait(false);
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);
}
}
}