UNPKG

2.11 kBJavaScriptView Raw
1import { platformNames } from '../common';
2class DeviceRef {
3 get manufacturer() {
4 return 'Apple';
5 }
6 get os() {
7 if (__VISIONOS__) {
8 return platformNames.visionos;
9 }
10 else {
11 return platformNames.ios;
12 }
13 }
14 get osVersion() {
15 if (!this._osVersion) {
16 this._osVersion = UIDevice.currentDevice.systemVersion;
17 }
18 return this._osVersion;
19 }
20 get model() {
21 if (!this._model) {
22 this._model = UIDevice.currentDevice.model;
23 }
24 return this._model;
25 }
26 get sdkVersion() {
27 if (!this._sdkVersion) {
28 this._sdkVersion = UIDevice.currentDevice.systemVersion;
29 }
30 return this._sdkVersion;
31 }
32 get deviceType() {
33 if (!this._deviceType) {
34 if (UIDevice.currentDevice.userInterfaceIdiom === 0 /* UIUserInterfaceIdiom.Phone */) {
35 this._deviceType = 'Phone';
36 }
37 else if (UIDevice.currentDevice.userInterfaceIdiom === 6 /* UIUserInterfaceIdiom.Vision */) {
38 this._deviceType = 'Tablet';
39 // TODO: could add conditions throughout core for this
40 // this._deviceType = 'Vision';
41 }
42 else {
43 this._deviceType = 'Tablet';
44 }
45 }
46 return this._deviceType;
47 }
48 get uuid() {
49 const userDefaults = NSUserDefaults.standardUserDefaults;
50 const uuid_key = 'TNSUUID';
51 let app_uuid = userDefaults.stringForKey(uuid_key);
52 if (!app_uuid) {
53 app_uuid = NSUUID.UUID().UUIDString;
54 userDefaults.setObjectForKey(app_uuid, uuid_key);
55 userDefaults.synchronize();
56 }
57 return app_uuid;
58 }
59 get language() {
60 return NSLocale.preferredLanguages[0];
61 }
62 get region() {
63 return NSLocale.currentLocale.objectForKey(NSLocaleCountryCode);
64 }
65}
66export const Device = new DeviceRef();
67// This retains compatibility with NS6
68export const device = Device;
69//# sourceMappingURL=index.ios.js.map
\No newline at end of file