1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | import { Platform, Dimensions } from 'react-native';
|
14 | import { ConsoleLogger as Logger } from '../Logger';
|
15 | var logger = new Logger('DeviceInfo');
|
16 | export var clientInfo = function () {
|
17 | var dim = Dimensions.get('screen');
|
18 | logger.debug(Platform, dim);
|
19 | var OS = 'ios';
|
20 | var Version = Platform.Version;
|
21 | var _a = dimToMake(dim), make = _a.make, model = _a.model;
|
22 | return {
|
23 | platform: OS,
|
24 | version: String(Version),
|
25 | appVersion: [OS, String(Version)].join('/'),
|
26 | make: make,
|
27 | model: model,
|
28 | };
|
29 | };
|
30 | function dimToMake(dim) {
|
31 | var height = dim.height, width = dim.width;
|
32 | if (height < width) {
|
33 | var tmp = height;
|
34 | height = width;
|
35 | width = tmp;
|
36 | }
|
37 | if (width === 320 && height === 568) {
|
38 | return { make: 'iPhone', model: 'iPhone 5' };
|
39 | }
|
40 | if (width === 375 && height === 667) {
|
41 | return { make: 'iPhone', model: 'iPhone 6/7/8' };
|
42 | }
|
43 | if (width === 414 && height === 736) {
|
44 | return { make: 'iPhone', model: 'iPhone 6/7/8 plus' };
|
45 | }
|
46 | if (width === 375 && height === 812) {
|
47 | return { make: 'iPhone', model: 'iPhone X' };
|
48 | }
|
49 | if (width === 414 && height === 896) {
|
50 | return { make: 'iPhone', model: 'iPhone XR' };
|
51 | }
|
52 | if (width === 768 && height === 1024) {
|
53 | return { make: 'iPad', model: 'iPad Mini/Air' };
|
54 | }
|
55 | if (width === 834 && height === 1112) {
|
56 | return { make: 'iPad', model: 'iPad Pro' };
|
57 | }
|
58 | if (width === 1024 && height === 1366) {
|
59 | return { make: 'iPad', model: 'iPad Pro' };
|
60 | }
|
61 | if (width === 272 && height === 340) {
|
62 | return { make: 'Watch', model: 'Watch 38mm' };
|
63 | }
|
64 | if (width === 312 && height === 390) {
|
65 | return { make: 'Watch', model: 'Watch 42mm' };
|
66 | }
|
67 | return { make: null, model: null };
|
68 | }
|
69 |
|
\ | No newline at end of file |