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

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