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
535e0b52
Commit
535e0b52
authored
Oct 17, 2016
by
Gant Laborde
Committed by
GitHub
Oct 17, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #93 from xsdlr/master
detect device is Simulator?
parents
911cb370
623408af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
0 deletions
+25
-0
README.md
README.md
+4
-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.
README.md
View file @
535e0b52
...
...
@@ -170,4 +170,8 @@ console.log("Device Country", DeviceInfo.getDeviceCountry()); // e.g US
console.log("Timezone", DeviceInfo.getTimezone()); // e.g America/Mexico_City
console.log("App Instance ID", DeviceInfo.getInstanceID()); // ANDROID ONLY - see https://developers.google.com/instance-id/
console.log("App is running in emulator", DeviceInfo.isEmulator()); // if app is running in emulator return true
``
`
RNDeviceInfo/RNDeviceInfo.m
View file @
535e0b52
...
...
@@ -152,6 +152,11 @@ RCT_EXPORT_MODULE()
return
currentTimeZone
.
name
;
}
-
(
bool
)
isEmulator
{
return
[
self
.
deviceName
isEqual
:
@"Simulator"
];
}
-
(
NSDictionary
*
)
constantsToExport
{
UIDevice
*
currentDevice
=
[
UIDevice
currentDevice
];
...
...
@@ -174,6 +179,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 @
535e0b52
...
...
@@ -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 @
535e0b52
...
...
@@ -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