Commit 3e420631 authored by Hamzeh Sharawi's avatar Hamzeh Sharawi

Merge pull request #1 from rebeccahughes/master

Up to date with original master
parents 75c40b63 6f773de9
...@@ -116,4 +116,6 @@ console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g. ...@@ -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("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)
``` ```
...@@ -120,6 +120,12 @@ RCT_EXPORT_MODULE() ...@@ -120,6 +120,12 @@ RCT_EXPORT_MODULE()
return deviceName; return deviceName;
} }
- (NSString*) userAgent
{
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
return [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
}
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
UIDevice *currentDevice = [UIDevice currentDevice]; UIDevice *currentDevice = [UIDevice currentDevice];
...@@ -138,6 +144,7 @@ RCT_EXPORT_MODULE() ...@@ -138,6 +144,7 @@ RCT_EXPORT_MODULE()
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
@"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"], @"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
@"systemManufacturer": @"Apple", @"systemManufacturer": @"Apple",
@"userAgent": self.userAgent,
}; };
} }
......
...@@ -67,6 +67,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -67,6 +67,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
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);
constants.put("userAgent", System.getProperty("http.agent"));
return constants; return constants;
} }
} }
...@@ -37,5 +37,8 @@ module.exports = { ...@@ -37,5 +37,8 @@ module.exports = {
}, },
getDeviceName: function() { getDeviceName: function() {
return RNDeviceInfo.deviceName; return RNDeviceInfo.deviceName;
},
getUserAgent: function() {
return RNDeviceInfo.userAgent;
} }
}; };
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