Commit a302e076 authored by Richard Evans's avatar Richard Evans

Provide the device's user agent

parent 75c40b63
...@@ -120,6 +120,12 @@ RCT_EXPORT_MODULE() ...@@ -120,6 +120,12 @@ RCT_EXPORT_MODULE()
return deviceName; return deviceName;
} }
- (NSString*) userAgent
{
UIWebView *webView = [[UIWebView alloc] initiWithFrame: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