Commit 10d8d142 authored by Rebecca Hughes's avatar Rebecca Hughes

Merge pull request #11 from Sh3rawi/device_locale

Device locale
parents 6f773de9 4a235531
...@@ -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
``` ```
...@@ -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"],
......
...@@ -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);
......
...@@ -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;
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment