1 | import { platformNames } from '../common';
|
2 | class 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 ) {
|
35 | this._deviceType = 'Phone';
|
36 | }
|
37 | else if (UIDevice.currentDevice.userInterfaceIdiom === 6 ) {
|
38 | this._deviceType = 'Tablet';
|
39 |
|
40 |
|
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 | }
|
66 | export const Device = new DeviceRef();
|
67 |
|
68 | export const device = Device;
|
69 |
|
\ | No newline at end of file |