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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from '../../base/redux';
  4. import { createDeepLinkingPageEvent, sendAnalytics } from '../../analytics';
  5. import { translate } from '../../base/i18n';
  6. import { Platform } from '../../base/react';
  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. <a
  110. { ...onOpenLinkProperties }
  111. href = { this._generateDownloadURL() }
  112. onClick = { this._onDownloadApp }>
  113. <button className = { downloadButtonClassName }>
  114. { t(`${_TNS}.downloadApp`) }
  115. </button>
  116. target = '_top'
  117. </a>
  118. <a
  119. { ...onOpenLinkProperties }
  120. className = { `${_SNS}__href` }
  121. href = { generateDeepLinkingURL() }
  122. onClick = { this._onOpenApp }>
  123. {/* <button className = { `${_SNS}__button` }> */}
  124. { t(`${_TNS}.openApp`) }
  125. {/* </button> */}
  126. target = '_top'
  127. </a>
  128. { renderPromotionalFooter() }
  129. <DialInSummary
  130. className = 'deep-linking-dial-in'
  131. clickableNumbers = { true }
  132. room = { _room } />
  133. </div>
  134. </div>
  135. );
  136. }
  137. /**
  138. * Generates the URL for downloading the app.
  139. *
  140. * @private
  141. * @returns {string} - The URL for downloading the app.
  142. */
  143. _generateDownloadURL() {
  144. const { _downloadUrl: url } = this.props;
  145. if (url && typeof interfaceConfig.MOBILE_DYNAMIC_LINK === 'undefined') {
  146. return url;
  147. }
  148. // For information about the properties of
  149. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  150. // https://firebase.google.com/docs/dynamic-links/create-manually
  151. const {
  152. APN = 'org.jitsi.meet',
  153. APP_CODE = 'w2atb',
  154. CUSTOM_DOMAIN = undefined,
  155. IBI = 'com.atlassian.JitsiMeet.ios',
  156. ISI = '1165103905'
  157. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  158. const domain = CUSTOM_DOMAIN ?? `https://${APP_CODE}.app.goo.gl`;
  159. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  160. return `${domain}/?link=${
  161. encodeURIComponent(window.location.href)}&apn=${
  162. APN}&ibi=${
  163. IBI}&isi=${
  164. ISI}&ius=${
  165. IUS}&efr=1`;
  166. }
  167. _onDownloadApp: () => void;
  168. /**
  169. * Handles download app button clicks.
  170. *
  171. * @private
  172. * @returns {void}
  173. */
  174. _onDownloadApp() {
  175. sendAnalytics(
  176. createDeepLinkingPageEvent(
  177. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  178. }
  179. _onOpenApp: () => void;
  180. /**
  181. * Handles open app button clicks.
  182. *
  183. * @private
  184. * @returns {void}
  185. */
  186. _onOpenApp() {
  187. sendAnalytics(
  188. createDeepLinkingPageEvent(
  189. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  190. }
  191. }
  192. /**
  193. * Maps (parts of) the Redux state to the associated props for the
  194. * {@code DeepLinkingMobilePage} component.
  195. *
  196. * @param {Object} state - The Redux state.
  197. * @private
  198. * @returns {Props}
  199. */
  200. function _mapStateToProps(state) {
  201. return {
  202. _downloadUrl: interfaceConfig[`MOBILE_DOWNLOAD_LINK_${Platform.OS.toUpperCase()}`],
  203. _room: decodeURIComponent(state['features/base/conference'].room)
  204. };
  205. }
  206. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));