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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 map of platforms to URLs at which the mobile app for the associated
  21. * platform is available for download.
  22. *
  23. * @private
  24. * @type {Array<string>}
  25. */
  26. const _URLS = {
  27. android: interfaceConfig.MOBILE_DOWNLOAD_LINK_ANDROID,
  28. ios: interfaceConfig.MOBILE_DOWNLOAD_LINK_IOS
  29. };
  30. /**
  31. * The type of the React {@code Component} props of
  32. * {@link DeepLinkingMobilePage}.
  33. */
  34. type Props = {
  35. /**
  36. * The name of the conference attempting to being joined.
  37. */
  38. _room: string,
  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._onOpenApp = this._onOpenApp.bind(this);
  61. }
  62. /**
  63. * Implements the Component's componentDidMount method.
  64. *
  65. * @inheritdoc
  66. */
  67. componentDidMount() {
  68. sendAnalytics(
  69. createDeepLinkingPageEvent(
  70. 'displayed', 'DeepLinkingMobile', { isMobileBrowser: true }));
  71. }
  72. /**
  73. * Implements React's {@link Component#render()}.
  74. *
  75. * @inheritdoc
  76. * @returns {ReactElement}
  77. */
  78. render() {
  79. const { _room, t } = this.props;
  80. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  81. const downloadButtonClassName
  82. = `${_SNS}__button ${_SNS}__button_primary`;
  83. return (
  84. <div className = { _SNS }>
  85. <div className = 'header'>
  86. <img
  87. className = 'logo'
  88. src = 'images/logo-deep-linking.png' />
  89. </div>
  90. <div className = { `${_SNS}__body` }>
  91. {
  92. SHOW_DEEP_LINKING_IMAGE
  93. ? <img
  94. className = 'image'
  95. src = 'images/deep-linking-image.png' />
  96. : null
  97. }
  98. <p className = { `${_SNS}__text` }>
  99. { t(`${_TNS}.appNotInstalled`, { app: NATIVE_APP_NAME }) }
  100. </p>
  101. <a
  102. href = { this._generateDownloadURL() }
  103. onClick = { this._onDownloadApp }
  104. rel = 'noopener noreferrer'
  105. target = '_blank'>
  106. <button className = { downloadButtonClassName }>
  107. { t(`${_TNS}.downloadApp`) }
  108. </button>
  109. </a>
  110. <a
  111. className = { `${_SNS}__href` }
  112. href = { generateDeepLinkingURL() }
  113. onClick = { this._onOpenApp }
  114. rel = 'noopener noreferrer'
  115. target = '_blank'>
  116. {/* <button className = { `${_SNS}__button` }> */}
  117. { t(`${_TNS}.openApp`) }
  118. {/* </button> */}
  119. </a>
  120. { renderPromotionalFooter() }
  121. <DialInSummary
  122. className = 'deep-linking-dial-in'
  123. clickableNumbers = { true }
  124. room = { _room } />
  125. </div>
  126. </div>
  127. );
  128. }
  129. /**
  130. * Generates the URL for downloading the app.
  131. *
  132. * @private
  133. * @returns {string} - The URL for downloading the app.
  134. */
  135. _generateDownloadURL() {
  136. const url = _URLS[Platform.OS];
  137. if (url) {
  138. return url;
  139. }
  140. // For information about the properties of
  141. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  142. // https://firebase.google.com/docs/dynamic-links/create-manually
  143. const {
  144. APN = 'org.jitsi.meet',
  145. APP_CODE = 'w2atb',
  146. IBI = 'com.atlassian.JitsiMeet.ios',
  147. ISI = '1165103905'
  148. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  149. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  150. return `https://${APP_CODE}.app.goo.gl/?link=${
  151. encodeURIComponent(window.location.href)}&apn=${
  152. APN}&ibi=${
  153. IBI}&isi=${
  154. ISI}&ius=${
  155. IUS}&efr=1`;
  156. }
  157. _onDownloadApp: () => void;
  158. /**
  159. * Handles download app button clicks.
  160. *
  161. * @private
  162. * @returns {void}
  163. */
  164. _onDownloadApp() {
  165. sendAnalytics(
  166. createDeepLinkingPageEvent(
  167. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  168. }
  169. _onOpenApp: () => void;
  170. /**
  171. * Handles open app button clicks.
  172. *
  173. * @private
  174. * @returns {void}
  175. */
  176. _onOpenApp() {
  177. sendAnalytics(
  178. createDeepLinkingPageEvent(
  179. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  180. }
  181. }
  182. /**
  183. * Maps (parts of) the Redux state to the associated props for the
  184. * {@code DeepLinkingMobilePage} component.
  185. *
  186. * @param {Object} state - The Redux state.
  187. * @private
  188. * @returns {{
  189. * _room: string
  190. * }}
  191. */
  192. function _mapStateToProps(state) {
  193. return {
  194. _room: decodeURIComponent(state['features/base/conference'].room)
  195. };
  196. }
  197. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));