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

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