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

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