Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-device-info
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-device-info
Commits
9887f878
Commit
9887f878
authored
Sep 21, 2017
by
Gant Laborde
Committed by
GitHub
Sep 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #224 from douglasjunior/patch-1
Added device detection even when in an iOS emulator.
parents
40e1b51c
45463d87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
RNDeviceInfo.m
RNDeviceInfo/RNDeviceInfo.m
+20
-13
No files found.
RNDeviceInfo/RNDeviceInfo.m
View file @
9887f878
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#import <LocalAuthentication/LocalAuthentication.h>
#import <LocalAuthentication/LocalAuthentication.h>
@interface
RNDeviceInfo
()
@interface
RNDeviceInfo
()
@property
(
nonatomic
)
bool
isEmulator
;
@end
@end
@implementation
RNDeviceInfo
@implementation
RNDeviceInfo
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
}
}
@synthesize
isEmulator
;
RCT_EXPORT_MODULE
()
RCT_EXPORT_MODULE
()
-
(
dispatch_queue_t
)
methodQueue
-
(
dispatch_queue_t
)
methodQueue
...
@@ -31,9 +33,18 @@ RCT_EXPORT_MODULE()
...
@@ -31,9 +33,18 @@ RCT_EXPORT_MODULE()
struct
utsname
systemInfo
;
struct
utsname
systemInfo
;
uname
(
&
systemInfo
);
uname
(
&
systemInfo
);
return
[
NSString
stringWithCString
:
systemInfo
.
machine
NSString
*
deviceId
=
[
NSString
stringWithCString
:
systemInfo
.
machine
encoding
:
NSUTF8StringEncoding
];
encoding
:
NSUTF8StringEncoding
];
if
([
deviceId
isEqualToString
:
@"i386"
]
||
[
deviceId
isEqualToString
:
@"x86_64"
]
)
{
deviceId
=
[
NSString
stringWithFormat
:
@"%s"
,
getenv
(
"SIMULATOR_MODEL_IDENTIFIER"
)];
self
.
isEmulator
=
YES
;
}
else
{
self
.
isEmulator
=
NO
;
}
return
deviceId
;
}
}
-
(
NSString
*
)
deviceName
-
(
NSString
*
)
deviceName
...
@@ -41,10 +52,8 @@ RCT_EXPORT_MODULE()
...
@@ -41,10 +52,8 @@ RCT_EXPORT_MODULE()
static
NSDictionary
*
deviceNamesByCode
=
nil
;
static
NSDictionary
*
deviceNamesByCode
=
nil
;
if
(
!
deviceNamesByCode
)
{
if
(
!
deviceNamesByCode
)
{
deviceNamesByCode
=
@{
@"i386"
:
@"Simulator"
,
deviceNamesByCode
=
@{
@"iPod1,1"
:
@"iPod Touch"
,
// (Original)
@"x86_64"
:
@"Simulator"
,
@"iPod1,1"
:
@"iPod Touch"
,
// (Original)
@"iPod2,1"
:
@"iPod Touch"
,
// (Second Generation)
@"iPod2,1"
:
@"iPod Touch"
,
// (Second Generation)
@"iPod3,1"
:
@"iPod Touch"
,
// (Third Generation)
@"iPod3,1"
:
@"iPod Touch"
,
// (Third Generation)
@"iPod4,1"
:
@"iPod Touch"
,
// (Fourth Generation)
@"iPod4,1"
:
@"iPod Touch"
,
// (Fourth Generation)
...
@@ -86,6 +95,9 @@ RCT_EXPORT_MODULE()
...
@@ -86,6 +95,9 @@ RCT_EXPORT_MODULE()
@"iPhone9,3"
:
@"iPhone 7"
,
// (model A1778 | Global)
@"iPhone9,3"
:
@"iPhone 7"
,
// (model A1778 | Global)
@"iPhone9,2"
:
@"iPhone 7 Plus"
,
// (model A1661 | CDMA)
@"iPhone9,2"
:
@"iPhone 7 Plus"
,
// (model A1661 | CDMA)
@"iPhone9,4"
:
@"iPhone 7 Plus"
,
// (model A1784 | Global)
@"iPhone9,4"
:
@"iPhone 7 Plus"
,
// (model A1784 | Global)
@"iPhone10,3"
:
@"iPhone X"
,
//
@"iPhone10,4"
:
@"iPhone 8"
,
//
@"iPhone10,5"
:
@"iPhone 8 Plus"
,
//
@"iPad4,1"
:
@"iPad Air"
,
// 5th Generation iPad (iPad Air) - Wifi
@"iPad4,1"
:
@"iPad Air"
,
// 5th Generation iPad (iPad Air) - Wifi
@"iPad4,2"
:
@"iPad Air"
,
// 5th Generation iPad (iPad Air) - Cellular
@"iPad4,2"
:
@"iPad Air"
,
// 5th Generation iPad (iPad Air) - Cellular
@"iPad4,3"
:
@"iPad Air"
,
// 5th Generation iPad (iPad Air)
@"iPad4,3"
:
@"iPad Air"
,
// 5th Generation iPad (iPad Air)
...
@@ -153,11 +165,6 @@ RCT_EXPORT_MODULE()
...
@@ -153,11 +165,6 @@ RCT_EXPORT_MODULE()
return
currentTimeZone
.
name
;
return
currentTimeZone
.
name
;
}
}
-
(
bool
)
isEmulator
{
return
[
self
.
deviceName
isEqual
:
@"Simulator"
];
}
-
(
bool
)
isTablet
-
(
bool
)
isTablet
{
{
return
[[
UIDevice
currentDevice
]
userInterfaceIdiom
]
==
UIUserInterfaceIdiomPad
;
return
[[
UIDevice
currentDevice
]
userInterfaceIdiom
]
==
UIUserInterfaceIdiomPad
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment