Skip to content

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

android: fix deep-linking from web

Saúl Ibarra Corretgée729f0948cc5
diff --git a/interface_config.js b/interface_config.js
index 8505ad8eea..46db0a3487 100644
--- a/interface_config.js
+++ b/interface_config.js
@@ -192,7 +192,12 @@ var interfaceConfig = {
/**
* Specify mobile app scheme for opening the app from the mobile browser.
*/
- // APP_SCHEME: 'org.jitsi.meet'
+ // APP_SCHEME: 'org.jitsi.meet',
+
+ /**
+ * Specify the Android app package name.
+ */
+ // ANDROID_APP_PACKAGE: 'org.jitsi.meet'
};
/* eslint-enable no-unused-vars, no-var, max-len */
diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.js
index 267be01d70..de9e9c4eab 100644
--- a/react/features/base/util/uri.js
+++ b/react/features/base/util/uri.js
@@ -41,7 +41,7 @@ const _URI_PATH_PATTERN = '([^?#]*)';
*
* @type {string}
*/
-export const URI_PROTOCOL_PATTERN = '([a-z][a-z0-9\\.\\+-]*:)';
+export const URI_PROTOCOL_PATTERN = '^([a-z][a-z0-9\\.\\+-]*:)';
/**
* Excludes/removes certain characters from a specific room (name) which are
@@ -71,7 +71,7 @@ function _fixRoom(room: ?string) {
* @returns {string}
*/
function _fixURIStringScheme(uri: string) {
- const regex = new RegExp(`^${URI_PROTOCOL_PATTERN}+`, 'gi');
+ const regex = new RegExp(`${URI_PROTOCOL_PATTERN}+`, 'gi');
const match: Array<string> | null = regex.exec(uri);
if (match) {
@@ -175,7 +175,7 @@ export function parseStandardURIString(str: string) {
str = str.replace(/\s/g, '');
// protocol
- regex = new RegExp(`^${URI_PROTOCOL_PATTERN}`, 'gi');
+ regex = new RegExp(URI_PROTOCOL_PATTERN, 'gi');
match = regex.exec(str);
if (match) {
obj.protocol = match[1].toLowerCase();
diff --git a/react/features/deep-linking/components/DeepLinkingMobilePage.web.js b/react/features/deep-linking/components/DeepLinkingMobilePage.web.js
index 91d40c2534..d20a785e2a 100644
--- a/react/features/deep-linking/components/DeepLinkingMobilePage.web.js
+++ b/react/features/deep-linking/components/DeepLinkingMobilePage.web.js
@@ -50,28 +50,12 @@ type Props = {
t: Function
};
-/**
- * The type of the React {@code Component} state of
- * {@link DeepLinkingMobilePage}.
- */
-type State = {
-
- /**
- * The URL to link to on the button for opening the mobile app.
- */
- joinURL: string
-};
-
/**
* React component representing mobile browser page.
*
* @class DeepLinkingMobilePage
*/
-class DeepLinkingMobilePage extends Component<Props, State> {
- state = {
- joinURL: ''
- };
-
+class DeepLinkingMobilePage extends Component<Props> {
/**
* Initializes a new {@code DeepLinkingMobilePage} instance.
*
@@ -81,10 +65,6 @@ class DeepLinkingMobilePage extends Component<Props, State> {
constructor(props: Props) {
super(props);
- this.state = {
- joinURL: generateDeepLinkingURL()
- };
-
// Bind event handlers so they are only bound once per instance.
this._onDownloadApp = this._onDownloadApp.bind(this);
this._onOpenApp = this._onOpenApp.bind(this);
@@ -147,7 +127,7 @@ class DeepLinkingMobilePage extends Component<Props, State> {
</a>
<a
className = { `${_SNS}__href` }
- href = { this.state.joinURL }
+ href = { generateDeepLinkingURL() }
onClick = { this._onOpenApp }
rel = 'noopener noreferrer'
target = '_blank'>
diff --git a/react/features/deep-linking/functions.js b/react/features/deep-linking/functions.js
index 54345ae7c6..fc17ea12b1 100644
--- a/react/features/deep-linking/functions.js
+++ b/react/features/deep-linking/functions.js
@@ -42,12 +42,23 @@ export function generateDeepLinkingURL() {
// like to open the current URL in the mobile app. The only way to do it
// appears to be a link with an app-specific scheme, not a Universal
// Link.
+
const appScheme = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
+ const { href } = window.location;
+ const regex = new RegExp(URI_PROTOCOL_PATTERN, 'gi');
+
+ // Android: use an intent link, custom schemes don't work in all browsers.
+ // https://developer.chrome.com/multidevice/android/intents
+ if (Platform.OS === 'android') {
+ // https://meet.jit.si/foo -> meet.jit.si/foo
+ const url = href.replace(regex, '').substr(3);
+ const pkg = interfaceConfig.ANDROID_APP_PACKAGE || 'org.jitsi.meet';
- // Replace the protocol part with the app scheme.
+ return `intent://${url}/#Intent;scheme=${appScheme};package=${pkg};end`;
+ }
- return window.location.href.replace(
- new RegExp(`^${URI_PROTOCOL_PATTERN}`), `${appScheme}:`);
+ // iOS: Replace the protocol part with the app scheme.
+ return href.replace(regex, `${appScheme}:`);
}
/**