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

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