android: fix deep-linking from web

Looks like custom-scheme links no longer work in all browsers. They do on
Firefox, but the don't in Chrome and other default browsers.

So, switch to intent links on Android:
https://developer.chrome.com/multidevice/android/intents

Example:
```
<a href="intent://meet.jit.si/test123#Intent;scheme=org.jitsi.meet;package=org.jitsi.meet;end">Open Jitsi Meet</a>
```
This commit is contained in:
Saúl Ibarra Corretgé 2019-01-30 13:16:50 +01:00 committed by Saúl Ibarra Corretgé
parent 6f57d58dd9
commit e729f0948c
4 changed files with 25 additions and 29 deletions

View File

@ -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 */

View File

@ -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();

View File

@ -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'>

View File

@ -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');
// Replace the protocol part with the app scheme.
// 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';
return window.location.href.replace(
new RegExp(`^${URI_PROTOCOL_PATTERN}`), `${appScheme}:`);
return `intent://${url}/#Intent;scheme=${appScheme};package=${pkg};end`;
}
// iOS: Replace the protocol part with the app scheme.
return href.replace(regex, `${appScheme}:`);
}
/**