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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. ? (
  151. <a
  152. onClick = { this._onLaunchWeb }
  153. target = '_top'>
  154. <button className = { downloadButtonClassName }>
  155. { t(`${_TNS}.launchWebButton`) }
  156. </button>
  157. </a>
  158. ) : (
  159. <b>
  160. { t(`${_TNS}.unsupportedBrowser`) }
  161. </b>
  162. )
  163. }
  164. { renderPromotionalFooter() }
  165. <DialInSummary
  166. className = 'deep-linking-dial-in'
  167. clickableNumbers = { true }
  168. room = { _room } />
  169. </div>
  170. </div>
  171. );
  172. }
  173. /**
  174. * Generates the URL for downloading the app.
  175. *
  176. * @private
  177. * @returns {string} - The URL for downloading the app.
  178. */
  179. _generateDownloadURL() {
  180. const { _downloadUrl: url } = this.props;
  181. if (url && typeof interfaceConfig.MOBILE_DYNAMIC_LINK === 'undefined') {
  182. return url;
  183. }
  184. // For information about the properties of
  185. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  186. // https://firebase.google.com/docs/dynamic-links/create-manually
  187. const {
  188. APN = 'org.jitsi.meet',
  189. APP_CODE = 'w2atb',
  190. CUSTOM_DOMAIN = undefined,
  191. IBI = 'com.atlassian.JitsiMeet.ios',
  192. ISI = '1165103905'
  193. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  194. const domain = CUSTOM_DOMAIN ?? `https://${APP_CODE}.app.goo.gl`;
  195. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  196. return `${domain}/?link=${
  197. encodeURIComponent(window.location.href)}&apn=${
  198. APN}&ibi=${
  199. IBI}&isi=${
  200. ISI}&ius=${
  201. IUS}&efr=1`;
  202. }
  203. _onDownloadApp: () => void;
  204. /**
  205. * Handles download app button clicks.
  206. *
  207. * @private
  208. * @returns {void}
  209. */
  210. _onDownloadApp() {
  211. sendAnalytics(
  212. createDeepLinkingPageEvent(
  213. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  214. }
  215. _onLaunchWeb: () => void;
  216. /**
  217. * Handles launch web button clicks.
  218. *
  219. * @returns {void}
  220. */
  221. _onLaunchWeb() {
  222. sendAnalytics(
  223. createDeepLinkingPageEvent(
  224. 'clicked', 'launchWebButton', { isMobileBrowser: true }));
  225. this.props.dispatch(openWebApp());
  226. }
  227. _onOpenApp: () => void;
  228. /**
  229. * Handles open app button clicks.
  230. *
  231. * @private
  232. * @returns {void}
  233. */
  234. _onOpenApp() {
  235. sendAnalytics(
  236. createDeepLinkingPageEvent(
  237. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  238. }
  239. }
  240. /**
  241. * Maps (parts of) the Redux state to the associated props for the
  242. * {@code DeepLinkingMobilePage} component.
  243. *
  244. * @param {Object} state - The Redux state.
  245. * @private
  246. * @returns {Props}
  247. */
  248. function _mapStateToProps(state) {
  249. return {
  250. _downloadUrl: interfaceConfig[`MOBILE_DOWNLOAD_LINK_${Platform.OS.toUpperCase()}`],
  251. _room: decodeURIComponent(state['features/base/conference'].room)
  252. };
  253. }
  254. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));