feat(DeepLinkingMobilePage): Add dynamic links support.

This commit is contained in:
hristoterezov 2018-05-08 16:04:26 +03:00 committed by Lyubo Marinov
parent 44a65eb329
commit 53971d0b50
1 changed files with 37 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* @flow */
// @flow
import PropTypes from 'prop-types';
import React, { Component } from 'react';
@ -30,10 +30,8 @@ const _SNS = 'deep-linking-mobile';
* @type {Array<string>}
*/
const _URLS = {
android: interfaceConfig.MOBILE_DOWNLOAD_LINK_ANDROID
|| 'https://play.google.com/store/apps/details?id=org.jitsi.meet',
android: interfaceConfig.MOBILE_DOWNLOAD_LINK_ANDROID,
ios: interfaceConfig.MOBILE_DOWNLOAD_LINK_IOS
|| 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905'
};
/**
@ -137,7 +135,7 @@ class DeepLinkingMobilePage extends Component<*, *> {
}
</p>
<a
href = { _URLS[Platform.OS] }
href = { this._generateDownloadURL() }
onClick = { this._onDownloadApp } >
<button className = { downloadButtonClassName }>
{ t(`${_TNS}.downloadApp`) }
@ -161,11 +159,44 @@ class DeepLinkingMobilePage extends Component<*, *> {
);
}
/**
* Generates the URL for downloading the app.
*
* @private
* @returns {string} - The URL for downloading the app.
*/
_generateDownloadURL() {
const url = _URLS[Platform.OS];
if (url) {
return url;
}
// For information about the properties of
// interfaceConfig.MOBILE_DYNAMIC_LINK check:
// https://firebase.google.com/docs/dynamic-links/create-manually
const {
APN = 'org.jitsi.meet',
APP_CODE = 'w2atb',
IBI = 'com.atlassian.JitsiMeet.ios',
ISI = '1165103905'
} = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
return `https://${APP_CODE}.app.goo.gl/?link=${
encodeURIComponent(window.location.href)}&apn=${
APN}&ibi=${
IBI}&isi=${
ISI}&ius=${
IUS}&efr=1`;
}
_onDownloadApp: () => {};
/**
* Handles download app button clicks.
*
* @private
* @returns {void}
*/
_onDownloadApp() {
@ -179,6 +210,7 @@ class DeepLinkingMobilePage extends Component<*, *> {
/**
* Handles open app button clicks.
*
* @private
* @returns {void}
*/
_onOpenApp() {