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
0021bb10
Commit
0021bb10
authored
Sep 08, 2016
by
消失的旅人
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加模拟器判断
parent
92c94a11
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
RNDeviceInfo.m
RNDeviceInfo/RNDeviceInfo.m
+6
-0
RNDeviceModule.java
...c/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
+12
-0
deviceinfo.js
deviceinfo.js
+3
-0
No files found.
RNDeviceInfo/RNDeviceInfo.m
View file @
0021bb10
...
...
@@ -148,6 +148,11 @@ RCT_EXPORT_MODULE()
return
currentTimeZone
.
name
;
}
-
(
bool
)
isEmulator
{
return
self
.
deviceName
==
@"Simulator"
;
}
-
(
NSDictionary
*
)
constantsToExport
{
UIDevice
*
currentDevice
=
[
UIDevice
currentDevice
];
...
...
@@ -171,6 +176,7 @@ RCT_EXPORT_MODULE()
@"systemManufacturer"
:
@"Apple"
,
@"userAgent"
:
self
.
userAgent
,
@"timezone"
:
self
.
timezone
,
@"isEmulator"
:
@
(
self
.
isEmulator
),
};
}
...
...
android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
View file @
0021bb10
...
...
@@ -52,6 +52,17 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
return
current
.
getCountry
();
}
private
Boolean
isEmulator
()
{
return
Build
.
FINGERPRINT
.
startsWith
(
"generic"
)
||
Build
.
FINGERPRINT
.
startsWith
(
"unknown"
)
||
Build
.
MODEL
.
contains
(
"google_sdk"
)
||
Build
.
MODEL
.
contains
(
"Emulator"
)
||
Build
.
MODEL
.
contains
(
"Android SDK built for x86"
)
||
Build
.
MANUFACTURER
.
contains
(
"Genymotion"
)
||
(
Build
.
BRAND
.
startsWith
(
"generic"
)
&&
Build
.
DEVICE
.
startsWith
(
"generic"
))
||
"google_sdk"
.
equals
(
Build
.
PRODUCT
);
}
@Override
public
@Nullable
Map
<
String
,
Object
>
getConstants
()
{
HashMap
<
String
,
Object
>
constants
=
new
HashMap
<
String
,
Object
>();
...
...
@@ -94,6 +105,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants
.
put
(
"bundleId"
,
packageName
);
constants
.
put
(
"userAgent"
,
System
.
getProperty
(
"http.agent"
));
constants
.
put
(
"timezone"
,
TimeZone
.
getDefault
().
getID
());
constants
.
put
(
"isEmulator"
,
this
.
isEmulator
());
return
constants
;
}
}
deviceinfo.js
View file @
0021bb10
...
...
@@ -56,4 +56,7 @@ module.exports = {
getTimezone
:
function
()
{
return
RNDeviceInfo
.
timezone
;
},
isEmulator
:
function
()
{
return
RNDeviceInfo
.
isEmulator
;
},
};
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