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
10d8d142
Commit
10d8d142
authored
Jan 02, 2016
by
Rebecca Hughes
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11 from Sh3rawi/device_locale
Device locale
parents
6f773de9
4a235531
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
1 deletion
+14
-1
README.md
README.md
+2
-0
RNDeviceInfo.m
RNDeviceInfo/RNDeviceInfo.m
+8
-1
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 @
10d8d142
...
@@ -118,4 +118,6 @@ console.log("Device Name", DeviceInfo.getDeviceName()); // e.g. Becca's iPhone
...
@@ -118,4 +118,6 @@ console.log("Device Name", DeviceInfo.getDeviceName()); // e.g. Becca's iPhone
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)
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)
console
.
log
(
"Device Locale"
,
DeviceInfo
.
getDeviceLocale
());
// e.g en-US
```
```
RNDeviceInfo/RNDeviceInfo.m
View file @
10d8d142
...
@@ -116,7 +116,7 @@ RCT_EXPORT_MODULE()
...
@@ -116,7 +116,7 @@ RCT_EXPORT_MODULE()
deviceName
=
@"iPhone"
;
deviceName
=
@"iPhone"
;
}
}
}
}
return
deviceName
;
return
deviceName
;
}
}
...
@@ -126,6 +126,12 @@ RCT_EXPORT_MODULE()
...
@@ -126,6 +126,12 @@ RCT_EXPORT_MODULE()
return
[
webView
stringByEvaluatingJavaScriptFromString
:
@"navigator.userAgent"
];
return
[
webView
stringByEvaluatingJavaScriptFromString
:
@"navigator.userAgent"
];
}
}
-
(
NSString
*
)
deviceLocale
{
NSString
*
language
=
[[
NSLocale
preferredLanguages
]
objectAtIndex
:
0
];
return
language
;
}
-
(
NSDictionary
*
)
constantsToExport
-
(
NSDictionary
*
)
constantsToExport
{
{
UIDevice
*
currentDevice
=
[
UIDevice
currentDevice
];
UIDevice
*
currentDevice
=
[
UIDevice
currentDevice
];
...
@@ -139,6 +145,7 @@ RCT_EXPORT_MODULE()
...
@@ -139,6 +145,7 @@ RCT_EXPORT_MODULE()
@"model"
:
self
.
deviceName
,
@"model"
:
self
.
deviceName
,
@"deviceId"
:
self
.
deviceId
,
@"deviceId"
:
self
.
deviceId
,
@"deviceName"
:
currentDevice
.
name
,
@"deviceName"
:
currentDevice
.
name
,
@"deviceLocale"
:
self
.
deviceLocale
,
@"uniqueId"
:
uniqueId
,
@"uniqueId"
:
uniqueId
,
@"bundleId"
:
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
@"CFBundleIdentifier"
],
@"bundleId"
:
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
@"CFBundleIdentifier"
],
@"appVersion"
:
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
@"CFBundleShortVersionString"
],
@"appVersion"
:
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
@"CFBundleShortVersionString"
],
...
...
android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
View file @
10d8d142
...
@@ -64,6 +64,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
...
@@ -64,6 +64,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants
.
put
(
"systemVersion"
,
Build
.
VERSION
.
RELEASE
);
constants
.
put
(
"systemVersion"
,
Build
.
VERSION
.
RELEASE
);
constants
.
put
(
"model"
,
Build
.
MODEL
);
constants
.
put
(
"model"
,
Build
.
MODEL
);
constants
.
put
(
"deviceId"
,
Build
.
BOARD
);
constants
.
put
(
"deviceId"
,
Build
.
BOARD
);
constants
.
put
(
"deviceLocale"
,
this
.
reactContext
.
getResources
().
getConfiguration
().
locale
.
toString
());
constants
.
put
(
"uniqueId"
,
Secure
.
getString
(
this
.
reactContext
.
getContentResolver
(),
Secure
.
ANDROID_ID
));
constants
.
put
(
"uniqueId"
,
Secure
.
getString
(
this
.
reactContext
.
getContentResolver
(),
Secure
.
ANDROID_ID
));
constants
.
put
(
"systemManufacturer"
,
Build
.
MANUFACTURER
);
constants
.
put
(
"systemManufacturer"
,
Build
.
MANUFACTURER
);
constants
.
put
(
"bundleId"
,
packageName
);
constants
.
put
(
"bundleId"
,
packageName
);
...
...
deviceinfo.js
View file @
10d8d142
...
@@ -40,5 +40,8 @@ module.exports = {
...
@@ -40,5 +40,8 @@ module.exports = {
},
},
getUserAgent
:
function
()
{
getUserAgent
:
function
()
{
return
RNDeviceInfo
.
userAgent
;
return
RNDeviceInfo
.
userAgent
;
},
getDeviceLocale
:
function
()
{
return
RNDeviceInfo
.
deviceLocale
;
}
}
};
};
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