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
6f773de9
Commit
6f773de9
authored
Dec 30, 2015
by
Rebecca Hughes
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13 from rmevans9/master
Add UserAgent as an available bit of information
parents
75c40b63
a6020394
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
0 deletions
+13
-0
README.md
README.md
+2
-0
RNDeviceInfo.m
RNDeviceInfo/RNDeviceInfo.m
+7
-0
RNDeviceModule.java
...c/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
+1
-0
deviceinfo.js
deviceinfo.js
+3
-0
No files found.
README.md
View file @
6f773de9
...
...
@@ -116,4 +116,6 @@ console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g.
console
.
log
(
"Device Name"
,
DeviceInfo
.
getDeviceName
());
// e.g. Becca's iPhone 6
console
.
log
(
"User Agent"
,
DeviceInfo
.
getUserAgent
());
// e.g. Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)
```
RNDeviceInfo/RNDeviceInfo.m
View file @
6f773de9
...
...
@@ -120,6 +120,12 @@ RCT_EXPORT_MODULE()
return
deviceName
;
}
-
(
NSString
*
)
userAgent
{
UIWebView
*
webView
=
[[
UIWebView
alloc
]
initWithFrame
:
CGRectZero
];
return
[
webView
stringByEvaluatingJavaScriptFromString
:
@"navigator.userAgent"
];
}
-
(
NSDictionary
*
)
constantsToExport
{
UIDevice
*
currentDevice
=
[
UIDevice
currentDevice
];
...
...
@@ -138,6 +144,7 @@ RCT_EXPORT_MODULE()
@"appVersion"
:
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
@"CFBundleShortVersionString"
],
@"buildNumber"
:
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
@"CFBundleVersion"
],
@"systemManufacturer"
:
@"Apple"
,
@"userAgent"
:
self
.
userAgent
,
};
}
...
...
android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
View file @
6f773de9
...
...
@@ -67,6 +67,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants
.
put
(
"uniqueId"
,
Secure
.
getString
(
this
.
reactContext
.
getContentResolver
(),
Secure
.
ANDROID_ID
));
constants
.
put
(
"systemManufacturer"
,
Build
.
MANUFACTURER
);
constants
.
put
(
"bundleId"
,
packageName
);
constants
.
put
(
"userAgent"
,
System
.
getProperty
(
"http.agent"
));
return
constants
;
}
}
deviceinfo.js
View file @
6f773de9
...
...
@@ -37,5 +37,8 @@ module.exports = {
},
getDeviceName
:
function
()
{
return
RNDeviceInfo
.
deviceName
;
},
getUserAgent
:
function
()
{
return
RNDeviceInfo
.
userAgent
;
}
};
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