Adds os and version to react-native userAgent.

This commit is contained in:
Lyubo Marinov 2017-09-20 10:05:07 -05:00
parent 6d62e91ff1
commit 6a1eff917c
1 changed files with 14 additions and 16 deletions

View File

@ -307,27 +307,25 @@ function _visitNode(node, callback) {
// Required by:
// - lib-jitsi-meet/modules/RTC/adapter.screenshare.js
// - lib-jitsi-meet/modules/RTC/RTCBrowserType.js
(() => {
const reactNativePackageJSON = require('react-native/package.json');
let userAgent = reactNativePackageJSON.name || 'react-native';
let userAgent = navigator.userAgent || '';
const version = reactNativePackageJSON.version;
// react-native/version
const { name, version } = require('react-native/package.json');
let rn = name || 'react-native';
if (version) {
userAgent += `/${version}`;
}
version && (rn += `/${version}`);
if (userAgent.indexOf(rn) === -1) {
userAgent = userAgent ? `${rn} ${userAgent}` : rn;
}
if (typeof navigator.userAgent !== 'undefined') {
const s = navigator.userAgent.toString();
// (OS version)
const os = `(${Platform.OS} ${Platform.Version})`;
if (s.length > 0 && s.indexOf(userAgent) === -1) {
userAgent = `${s} ${userAgent}`;
}
}
if (userAgent.indexOf(os) === -1) {
userAgent = userAgent ? `${userAgent} ${os}` : os;
}
navigator.userAgent
= `${userAgent} (${Platform.OS} ${Platform.Version})`;
})();
navigator.userAgent = userAgent;
}
// sessionStorage