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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. className = 'logo'
  107. src = 'images/logo-deep-linking.png' />
  108. }
  109. </div>
  110. <div className = { `${_SNS}__body` }>
  111. {
  112. SHOW_DEEP_LINKING_IMAGE
  113. ? <img
  114. className = 'image'
  115. src = 'images/deep-linking-image.png' />
  116. : null
  117. }
  118. <p className = { `${_SNS}__text` }>
  119. { t(`${_TNS}.appNotInstalled`, { app: NATIVE_APP_NAME }) }
  120. </p>
  121. <p className = { `${_SNS}__text` }>
  122. { t(`${_TNS}.ifHaveApp`) }
  123. </p>
  124. <a
  125. { ...onOpenLinkProperties }
  126. className = { `${_SNS}__href` }
  127. href = { generateDeepLinkingURL() }
  128. onClick = { this._onOpenApp }
  129. target = '_top'>
  130. <button className = { `${_SNS}__button ${_SNS}__button_primary` }>
  131. { t(`${_TNS}.joinInApp`) }
  132. </button>
  133. </a>
  134. <p className = { `${_SNS}__text` }>
  135. { t(`${_TNS}.ifDoNotHaveApp`) }
  136. </p>
  137. <a
  138. { ...onOpenLinkProperties }
  139. href = { this._generateDownloadURL() }
  140. onClick = { this._onDownloadApp }
  141. target = '_top'>
  142. <button className = { downloadButtonClassName }>
  143. { t(`${_TNS}.downloadApp`) }
  144. </button>
  145. </a>
  146. {
  147. isSupportedMobileBrowser()
  148. && <a
  149. onClick = { this._onLaunchWeb }
  150. target = '_top'>
  151. <button className = { downloadButtonClassName }>
  152. { t(`${_TNS}.launchWebButton`) }
  153. </button>
  154. </a>
  155. }
  156. { renderPromotionalFooter() }
  157. <DialInSummary
  158. className = 'deep-linking-dial-in'
  159. clickableNumbers = { true }
  160. room = { _room } />
  161. </div>
  162. </div>
  163. );
  164. }
  165. /**
  166. * Generates the URL for downloading the app.
  167. *
  168. * @private
  169. * @returns {string} - The URL for downloading the app.
  170. */
  171. _generateDownloadURL() {
  172. const { _downloadUrl: url } = this.props;
  173. if (url && typeof interfaceConfig.MOBILE_DYNAMIC_LINK === 'undefined') {
  174. return url;
  175. }
  176. // For information about the properties of
  177. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  178. // https://firebase.google.com/docs/dynamic-links/create-manually
  179. const {
  180. APN = 'org.jitsi.meet',
  181. APP_CODE = 'w2atb',
  182. CUSTOM_DOMAIN = undefined,
  183. IBI = 'com.atlassian.JitsiMeet.ios',
  184. ISI = '1165103905'
  185. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  186. const domain = CUSTOM_DOMAIN ?? `https://${APP_CODE}.app.goo.gl`;
  187. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  188. return `${domain}/?link=${
  189. encodeURIComponent(window.location.href)}&apn=${
  190. APN}&ibi=${
  191. IBI}&isi=${
  192. ISI}&ius=${
  193. IUS}&efr=1`;
  194. }
  195. _onDownloadApp: () => void;
  196. /**
  197. * Handles download app button clicks.
  198. *
  199. * @private
  200. * @returns {void}
  201. */
  202. _onDownloadApp() {
  203. sendAnalytics(
  204. createDeepLinkingPageEvent(
  205. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  206. }
  207. _onLaunchWeb: () => void;
  208. /**
  209. * Handles launch web button clicks.
  210. *
  211. * @returns {void}
  212. */
  213. _onLaunchWeb() {
  214. sendAnalytics(
  215. createDeepLinkingPageEvent(
  216. 'clicked', 'launchWebButton', { isMobileBrowser: true }));
  217. this.props.dispatch(openWebApp());
  218. }
  219. _onOpenApp: () => void;
  220. /**
  221. * Handles open app button clicks.
  222. *
  223. * @private
  224. * @returns {void}
  225. */
  226. _onOpenApp() {
  227. sendAnalytics(
  228. createDeepLinkingPageEvent(
  229. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  230. }
  231. }
  232. /**
  233. * Maps (parts of) the Redux state to the associated props for the
  234. * {@code DeepLinkingMobilePage} component.
  235. *
  236. * @param {Object} state - The Redux state.
  237. * @private
  238. * @returns {Props}
  239. */
  240. function _mapStateToProps(state) {
  241. return {
  242. _downloadUrl: interfaceConfig[`MOBILE_DOWNLOAD_LINK_${Platform.OS.toUpperCase()}`],
  243. _room: decodeURIComponent(state['features/base/conference'].room)
  244. };
  245. }
  246. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));