You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeepLinkingMobilePage.web.js 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. // @flow
  2. import React, { Component } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { createDeepLinkingPageEvent, sendAnalytics } from '../../analytics';
  5. import { isSupportedMobileBrowser } from '../../base/environment';
  6. import { translate } from '../../base/i18n';
  7. import { Platform } from '../../base/react';
  8. import { connect } from '../../base/redux';
  9. import { DialInSummary } from '../../invite';
  10. import { openWebApp } from '../actions';
  11. import { _TNS } from '../constants';
  12. import { generateDeepLinkingURL } from '../functions';
  13. import { renderPromotionalFooter } from '../renderPromotionalFooter';
  14. declare var interfaceConfig: Object;
  15. /**
  16. * The namespace of the CSS styles of DeepLinkingMobilePage.
  17. *
  18. * @private
  19. * @type {string}
  20. */
  21. const _SNS = 'deep-linking-mobile';
  22. /**
  23. * The type of the React {@code Component} props of
  24. * {@link DeepLinkingMobilePage}.
  25. */
  26. type Props = {
  27. /**
  28. * Application download URL.
  29. */
  30. _downloadUrl: ?string,
  31. /**
  32. * The name of the conference attempting to being joined.
  33. */
  34. _room: string,
  35. /**
  36. * Used to dispatch actions from the buttons.
  37. */
  38. dispatch: Dispatch<any>,
  39. /**
  40. * The function to translate human-readable text.
  41. */
  42. t: Function
  43. };
  44. /**
  45. * React component representing mobile browser page.
  46. *
  47. * @class DeepLinkingMobilePage
  48. */
  49. class DeepLinkingMobilePage extends Component<Props> {
  50. /**
  51. * Initializes a new {@code DeepLinkingMobilePage} instance.
  52. *
  53. * @param {Object} props - The read-only React {@code Component} props with
  54. * which the new instance is to be initialized.
  55. */
  56. constructor(props: Props) {
  57. super(props);
  58. // Bind event handlers so they are only bound once per instance.
  59. this._onDownloadApp = this._onDownloadApp.bind(this);
  60. this._onLaunchWeb = this._onLaunchWeb.bind(this);
  61. this._onOpenApp = this._onOpenApp.bind(this);
  62. }
  63. /**
  64. * Implements the Component's componentDidMount method.
  65. *
  66. * @inheritdoc
  67. */
  68. componentDidMount() {
  69. sendAnalytics(
  70. createDeepLinkingPageEvent(
  71. 'displayed', 'DeepLinkingMobile', { isMobileBrowser: true }));
  72. }
  73. /**
  74. * Implements React's {@link Component#render()}.
  75. *
  76. * @inheritdoc
  77. * @returns {ReactElement}
  78. */
  79. render() {
  80. const { _downloadUrl, _room, t } = this.props;
  81. const { HIDE_DEEP_LINKING_LOGO, NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  82. const downloadButtonClassName
  83. = `${_SNS}__button ${_SNS}__button_primary`;
  84. const onOpenLinkProperties = _downloadUrl
  85. ? {
  86. // When opening a link to the download page, we want to let the
  87. // OS itself handle intercepting and opening the appropriate
  88. // app store. This avoids potential issues with browsers, such
  89. // as iOS Chrome, not opening the store properly.
  90. }
  91. : {
  92. // When falling back to another URL (Firebase) let the page be
  93. // opened in a new window. This helps prevent the user getting
  94. // trapped in an app-open-cycle where going back to the mobile
  95. // browser re-triggers the app-open behavior.
  96. target: '_blank',
  97. rel: 'noopener noreferrer'
  98. };
  99. return (
  100. <div className = { _SNS }>
  101. <div className = 'header'>
  102. {
  103. HIDE_DEEP_LINKING_LOGO
  104. ? null
  105. : <img
  106. alt = { t('welcomepage.logo.logoDeepLinking') }
  107. className = 'logo'
  108. src = 'images/logo-deep-linking.png' />
  109. }
  110. </div>
  111. <div className = { `${_SNS}__body` }>
  112. {
  113. SHOW_DEEP_LINKING_IMAGE
  114. ? <img
  115. alt = { t('welcomepage.logo.logoDeepLinking') }
  116. className = 'image'
  117. src = 'images/deep-linking-image.png' />
  118. : null
  119. }
  120. <p className = { `${_SNS}__text` }>
  121. { t(`${_TNS}.appNotInstalled`, { app: NATIVE_APP_NAME }) }
  122. </p>
  123. <p className = { `${_SNS}__text` }>
  124. { t(`${_TNS}.ifHaveApp`) }
  125. </p>
  126. <a
  127. { ...onOpenLinkProperties }
  128. className = { `${_SNS}__href` }
  129. href = { generateDeepLinkingURL() }
  130. onClick = { this._onOpenApp }
  131. target = '_top'>
  132. <button className = { `${_SNS}__button ${_SNS}__button_primary` }>
  133. { t(`${_TNS}.joinInApp`) }
  134. </button>
  135. </a>
  136. <p className = { `${_SNS}__text` }>
  137. { t(`${_TNS}.ifDoNotHaveApp`) }
  138. </p>
  139. <a
  140. { ...onOpenLinkProperties }
  141. href = { this._generateDownloadURL() }
  142. onClick = { this._onDownloadApp }
  143. target = '_top'>
  144. <button className = { downloadButtonClassName }>
  145. { t(`${_TNS}.downloadApp`) }
  146. </button>
  147. </a>
  148. {
  149. isSupportedMobileBrowser()
  150. && <a
  151. onClick = { this._onLaunchWeb }
  152. target = '_top'>
  153. <button className = { downloadButtonClassName }>
  154. { t(`${_TNS}.launchWebButton`) }
  155. </button>
  156. </a>
  157. }
  158. { renderPromotionalFooter() }
  159. <DialInSummary
  160. className = 'deep-linking-dial-in'
  161. clickableNumbers = { true }
  162. room = { _room } />
  163. </div>
  164. </div>
  165. );
  166. }
  167. /**
  168. * Generates the URL for downloading the app.
  169. *
  170. * @private
  171. * @returns {string} - The URL for downloading the app.
  172. */
  173. _generateDownloadURL() {
  174. const { _downloadUrl: url } = this.props;
  175. if (url && typeof interfaceConfig.MOBILE_DYNAMIC_LINK === 'undefined') {
  176. return url;
  177. }
  178. // For information about the properties of
  179. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  180. // https://firebase.google.com/docs/dynamic-links/create-manually
  181. const {
  182. APN = 'org.jitsi.meet',
  183. APP_CODE = 'w2atb',
  184. CUSTOM_DOMAIN = undefined,
  185. IBI = 'com.atlassian.JitsiMeet.ios',
  186. ISI = '1165103905'
  187. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  188. const domain = CUSTOM_DOMAIN ?? `https://${APP_CODE}.app.goo.gl`;
  189. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  190. return `${domain}/?link=${
  191. encodeURIComponent(window.location.href)}&apn=${
  192. APN}&ibi=${
  193. IBI}&isi=${
  194. ISI}&ius=${
  195. IUS}&efr=1`;
  196. }
  197. _onDownloadApp: () => void;
  198. /**
  199. * Handles download app button clicks.
  200. *
  201. * @private
  202. * @returns {void}
  203. */
  204. _onDownloadApp() {
  205. sendAnalytics(
  206. createDeepLinkingPageEvent(
  207. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  208. }
  209. _onLaunchWeb: () => void;
  210. /**
  211. * Handles launch web button clicks.
  212. *
  213. * @returns {void}
  214. */
  215. _onLaunchWeb() {
  216. sendAnalytics(
  217. createDeepLinkingPageEvent(
  218. 'clicked', 'launchWebButton', { isMobileBrowser: true }));
  219. this.props.dispatch(openWebApp());
  220. }
  221. _onOpenApp: () => void;
  222. /**
  223. * Handles open app button clicks.
  224. *
  225. * @private
  226. * @returns {void}
  227. */
  228. _onOpenApp() {
  229. sendAnalytics(
  230. createDeepLinkingPageEvent(
  231. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  232. }
  233. }
  234. /**
  235. * Maps (parts of) the Redux state to the associated props for the
  236. * {@code DeepLinkingMobilePage} component.
  237. *
  238. * @param {Object} state - The Redux state.
  239. * @private
  240. * @returns {Props}
  241. */
  242. function _mapStateToProps(state) {
  243. return {
  244. _downloadUrl: interfaceConfig[`MOBILE_DOWNLOAD_LINK_${Platform.OS.toUpperCase()}`],
  245. _room: decodeURIComponent(state['features/base/conference'].room)
  246. };
  247. }
  248. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));