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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { createDeepLinkingPageEvent, sendAnalytics } from '../../analytics';
  5. import { translate, translateToHTML } 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. * The type of the React {@code Component} state of
  45. * {@link DeepLinkingMobilePage}.
  46. */
  47. type State = {
  48. /**
  49. * The URL to link to on the button for opening the mobile app.
  50. */
  51. joinURL: string
  52. };
  53. /**
  54. * React component representing mobile browser page.
  55. *
  56. * @class DeepLinkingMobilePage
  57. */
  58. class DeepLinkingMobilePage extends Component<Props, State> {
  59. state = {
  60. joinURL: ''
  61. };
  62. /**
  63. * Initializes a new {@code DeepLinkingMobilePage} instance.
  64. *
  65. * @param {Object} props - The read-only React {@code Component} props with
  66. * which the new instance is to be initialized.
  67. */
  68. constructor(props: Props) {
  69. super(props);
  70. // Bind event handlers so they are only bound once per instance.
  71. this._onDownloadApp = this._onDownloadApp.bind(this);
  72. this._onOpenApp = this._onOpenApp.bind(this);
  73. }
  74. /**
  75. * Initializes the text and URL of the `Start a conference` / `Join the
  76. * conversation` button which takes the user to the mobile app.
  77. *
  78. * @inheritdoc
  79. */
  80. componentWillMount() {
  81. this.setState({
  82. joinURL: generateDeepLinkingURL()
  83. });
  84. }
  85. /**
  86. * Implements the Component's componentDidMount method.
  87. *
  88. * @inheritdoc
  89. */
  90. componentDidMount() {
  91. sendAnalytics(
  92. createDeepLinkingPageEvent(
  93. 'displayed', 'DeepLinkingMobile', { isMobileBrowser: true }));
  94. }
  95. /**
  96. * Implements React's {@link Component#render()}.
  97. *
  98. * @inheritdoc
  99. * @returns {ReactElement}
  100. */
  101. render() {
  102. const { _room, t } = this.props;
  103. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  104. const downloadButtonClassName
  105. = `${_SNS}__button ${_SNS}__button_primary`;
  106. return (
  107. <div className = { _SNS }>
  108. <div className = 'header'>
  109. <img
  110. className = 'logo'
  111. src = 'images/logo-deep-linking.png' />
  112. </div>
  113. <div className = { `${_SNS}__body` }>
  114. {
  115. SHOW_DEEP_LINKING_IMAGE
  116. ? <img
  117. className = 'image'
  118. src = 'images/deep-linking-image.png' />
  119. : null
  120. }
  121. <p className = { `${_SNS}__text` }>
  122. {
  123. translateToHTML(
  124. t,
  125. `${_TNS}.appNotInstalled`,
  126. { app: NATIVE_APP_NAME })
  127. }
  128. </p>
  129. <a
  130. href = { this._generateDownloadURL() }
  131. onClick = { this._onDownloadApp } >
  132. <button className = { downloadButtonClassName }>
  133. { t(`${_TNS}.downloadApp`) }
  134. </button>
  135. </a>
  136. <a
  137. className = { `${_SNS}__href` }
  138. href = { this.state.joinURL }
  139. onClick = { this._onOpenApp }>
  140. {/* <button className = { `${_SNS}__button` }> */}
  141. { t(`${_TNS}.openApp`) }
  142. {/* </button> */}
  143. </a>
  144. <DialInSummary
  145. className = 'deep-linking-dial-in'
  146. clickableNumbers = { true }
  147. room = { _room } />
  148. </div>
  149. </div>
  150. );
  151. }
  152. /**
  153. * Generates the URL for downloading the app.
  154. *
  155. * @private
  156. * @returns {string} - The URL for downloading the app.
  157. */
  158. _generateDownloadURL() {
  159. const url = _URLS[Platform.OS];
  160. if (url) {
  161. return url;
  162. }
  163. // For information about the properties of
  164. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  165. // https://firebase.google.com/docs/dynamic-links/create-manually
  166. const {
  167. APN = 'org.jitsi.meet',
  168. APP_CODE = 'w2atb',
  169. IBI = 'com.atlassian.JitsiMeet.ios',
  170. ISI = '1165103905'
  171. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  172. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  173. return `https://${APP_CODE}.app.goo.gl/?link=${
  174. encodeURIComponent(window.location.href)}&apn=${
  175. APN}&ibi=${
  176. IBI}&isi=${
  177. ISI}&ius=${
  178. IUS}&efr=1`;
  179. }
  180. _onDownloadApp: () => {};
  181. /**
  182. * Handles download app button clicks.
  183. *
  184. * @private
  185. * @returns {void}
  186. */
  187. _onDownloadApp() {
  188. sendAnalytics(
  189. createDeepLinkingPageEvent(
  190. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  191. }
  192. _onOpenApp: () => {};
  193. /**
  194. * Handles open app button clicks.
  195. *
  196. * @private
  197. * @returns {void}
  198. */
  199. _onOpenApp() {
  200. sendAnalytics(
  201. createDeepLinkingPageEvent(
  202. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  203. }
  204. }
  205. /**
  206. * Maps (parts of) the Redux state to the associated props for the
  207. * {@code DeepLinkingMobilePage} component.
  208. *
  209. * @param {Object} state - The Redux state.
  210. * @private
  211. * @returns {{
  212. * _room: string
  213. * }}
  214. */
  215. function _mapStateToProps(state) {
  216. return {
  217. _room: state['features/base/conference'].room
  218. };
  219. }
  220. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));