Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Introduce Platform in React

Lyubomir Marinov5f21e4c5b650
diff --git a/react/features/app/components/App.native.js b/react/features/app/components/App.native.js
index a4a3d80920..db57f023c5 100644
--- a/react/features/app/components/App.native.js
+++ b/react/features/app/components/App.native.js
@@ -1,9 +1,11 @@
/* global __DEV__ */
import React from 'react';
-import { Linking, Navigator, Platform } from 'react-native';
+import { Linking, Navigator } from 'react-native';
import { Provider } from 'react-redux';
+import { Platform } from '../../base/react';
+
import { _getRouteToRender } from '../functions';
import { AbstractApp } from './AbstractApp';
diff --git a/react/features/base/lib-jitsi-meet/native/RTCPeerConnection.js b/react/features/base/lib-jitsi-meet/native/RTCPeerConnection.js
index 964f39fae8..5fd450fef3 100644
--- a/react/features/base/lib-jitsi-meet/native/RTCPeerConnection.js
+++ b/react/features/base/lib-jitsi-meet/native/RTCPeerConnection.js
@@ -1,9 +1,6 @@
-import { Platform } from 'react-native';
-import {
- RTCPeerConnection,
- RTCSessionDescription
-} from 'react-native-webrtc';
+import { RTCPeerConnection, RTCSessionDescription } from 'react-native-webrtc';
+import { Platform } from '../../react';
import { POSIX } from '../../react-native';
// XXX At the time of this writing extending RTCPeerConnection using ES6 'class'
diff --git a/react/features/base/media/components/native/Video.js b/react/features/base/media/components/native/Video.js
index 290bd99c0d..a933c7aa97 100644
--- a/react/features/base/media/components/native/Video.js
+++ b/react/features/base/media/components/native/Video.js
@@ -1,7 +1,9 @@
import React, { Component } from 'react';
-import { Platform, View } from 'react-native';
+import { View } from 'react-native';
import { RTCView } from 'react-native-webrtc';
+import { Platform } from '../../../react';
+
import { styles } from './styles';
/**
diff --git a/react/features/base/react/Platform.native.js b/react/features/base/react/Platform.native.js
new file mode 100644
index 0000000000..1710b20d30
--- /dev/null
+++ b/react/features/base/react/Platform.native.js
@@ -0,0 +1,4 @@
+// Re-export react-native's Platform because we want to provide a minimal
+// equivalent on Web.
+import { Platform } from 'react-native';
+export default Platform;
diff --git a/react/features/base/react/Platform.web.js b/react/features/base/react/Platform.web.js
new file mode 100644
index 0000000000..e09dda1335
--- /dev/null
+++ b/react/features/base/react/Platform.web.js
@@ -0,0 +1,20 @@
+const userAgent = navigator.userAgent;
+let OS;
+
+if (userAgent.match(/Android/i)) {
+ OS = 'android';
+} else if (userAgent.match(/iP(ad|hone|od)/i)) {
+ OS = 'ios';
+}
+
+/**
+ * Provides a minimal equivalent of react-native's Platform abstraction.
+ */
+export default {
+ /**
+ * The operating system on which the application is executing.
+ *
+ * @type {string}
+ */
+ OS
+};
diff --git a/react/features/base/react/index.js b/react/features/base/react/index.js
index fd27aa0de2..398bb49d78 100644
--- a/react/features/base/react/index.js
+++ b/react/features/base/react/index.js
@@ -1,3 +1,4 @@
export * from './components';
export * from './functions';
+export { default as Platform } from './Platform';
export { default as Symbol } from './Symbol';