This repository was archived by the owner on Sep 14, 2022. It is now read-only.
forked from nineto4/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
70 lines (60 loc) · 1.87 KB
/
CodePushUtils.cs
File metadata and controls
70 lines (60 loc) · 1.87 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Diagnostics;
using System.Linq;
using System.IO;
#if WINDOWS_UWP
using Windows.ApplicationModel;
using Windows.Storage;
#endif
namespace CodePush.ReactNative
{
internal partial class CodePushUtils
{
internal static void Log(string message)
{
Debug.WriteLine("[CodePush] " + message, CodePushConstants.ReactNativeLogCategory);
}
internal static void LogBundleUrl(string path)
{
Log("Loading JS bundle from \"" + path + "\"");
}
static string _deviceId = String.Empty;
internal static string GetDeviceId()
{
//It's quite long operation, cache it
if (!String.IsNullOrEmpty(_deviceId))
return _deviceId;
_deviceId = GetDeviceIdImpl();
return _deviceId;
}
internal static string GetAppVersion()
{
#if WINDOWS_UWP
return Package.Current.Id.Version.Major + "." + Package.Current.Id.Version.Minor + "." + Package.Current.Id.Version.Build;
#else
return applicationInfo.Version;
#endif
}
internal static string GetAppFolder()
{
#if WINDOWS_UWP
return ApplicationData.Current.LocalFolder.Path;
#else
return AppDomain.CurrentDomain.BaseDirectory;
#endif
}
internal static string GetAssetsBundlePrefix()
{
#if WINDOWS_UWP
return CodePushConstants.AssetsBundlePrefix;
#else
return Path.Combine(GetAppFolder(), CodePushConstants.AssetsBundlePrefix);
#endif
}
internal static string ExtractSubFolder(string fullPath)
{
var codePushSubPathArray = fullPath.Split(Path.DirectorySeparatorChar);
return String.Join("/", codePushSubPathArray.SkipWhile((value, index) => codePushSubPathArray.Length - index > 4).ToArray());
}
}
}