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

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