UNPKG

2.43 kBJavaScriptView Raw
1/*
2 * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5 * the License. A copy of the License is located at
6 *
7 * http://aws.amazon.com/apache2.0/
8 *
9 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11 * and limitations under the License.
12 */
13import { Platform, Dimensions } from 'react-native';
14import { ConsoleLogger as Logger } from '../Logger';
15var logger = new Logger('DeviceInfo');
16export 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};
30function 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//# sourceMappingURL=ios.js.map
\No newline at end of file