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 9.2KB

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