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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 { HideNotificationBarStyle, 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. || 'https://play.google.com/store/apps/details?id=org.jitsi.meet',
  29. ios: interfaceConfig.MOBILE_DOWNLOAD_LINK_IOS
  30. || 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905'
  31. };
  32. /**
  33. * React component representing mobile browser page.
  34. *
  35. * @class DeepLinkingMobilePage
  36. */
  37. class DeepLinkingMobilePage extends Component<*, *> {
  38. state: Object;
  39. /**
  40. * DeepLinkingMobilePage component's property types.
  41. *
  42. * @static
  43. */
  44. static propTypes = {
  45. /**
  46. * The name of the conference attempting to being joined.
  47. */
  48. _room: PropTypes.string,
  49. /**
  50. * The function to translate human-readable text.
  51. *
  52. * @public
  53. * @type {Function}
  54. */
  55. t: PropTypes.func
  56. };
  57. /**
  58. * Initializes a new {@code DeepLinkingMobilePage} instance.
  59. *
  60. * @param {Object} props - The read-only React {@code Component} props with
  61. * which the new instance is to be initialized.
  62. */
  63. constructor(props) {
  64. super(props);
  65. // Bind event handlers so they are only bound once per instance.
  66. this._onDownloadApp = this._onDownloadApp.bind(this);
  67. this._onOpenApp = this._onOpenApp.bind(this);
  68. }
  69. /**
  70. * Initializes the text and URL of the `Start a conference` / `Join the
  71. * conversation` button which takes the user to the mobile app.
  72. *
  73. * @inheritdoc
  74. */
  75. componentWillMount() {
  76. this.setState({
  77. joinURL: generateDeepLinkingURL()
  78. });
  79. }
  80. /**
  81. * Implements the Component's componentDidMount method.
  82. *
  83. * @inheritdoc
  84. */
  85. componentDidMount() {
  86. sendAnalytics(
  87. createDeepLinkingPageEvent(
  88. 'displayed', 'DeepLinkingMobile', { isMobileBrowser: true }));
  89. }
  90. /**
  91. * Implements React's {@link Component#render()}.
  92. *
  93. * @inheritdoc
  94. * @returns {ReactElement}
  95. */
  96. render() {
  97. const { _room, t } = this.props;
  98. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  99. const downloadButtonClassName
  100. = `${_SNS}__button ${_SNS}__button_primary`;
  101. return (
  102. <div className = { _SNS }>
  103. <div className = 'header'>
  104. <img
  105. className = 'logo'
  106. src = '../images/logo-deep-linking.png' />
  107. </div>
  108. <div className = { `${_SNS}__body` }>
  109. {
  110. SHOW_DEEP_LINKING_IMAGE
  111. ? <img
  112. className = 'image'
  113. src = '../images/deep-linking-image.png' />
  114. : null
  115. }
  116. <p className = { `${_SNS}__text` }>
  117. {
  118. translateToHTML(
  119. t,
  120. `${_TNS}.appNotInstalled`,
  121. { app: NATIVE_APP_NAME })
  122. }
  123. </p>
  124. <a
  125. href = { _URLS[Platform.OS] }
  126. onClick = { this._onDownloadApp } >
  127. <button className = { downloadButtonClassName }>
  128. { t(`${_TNS}.downloadApp`) }
  129. </button>
  130. </a>
  131. <a
  132. className = { `${_SNS}__href` }
  133. href = { this.state.joinURL }
  134. onClick = { this._onOpenApp }>
  135. {/* <button className = { `${_SNS}__button` }> */}
  136. { t(`${_TNS}.openApp`) }
  137. {/* </button> */}
  138. </a>
  139. <DialInSummary
  140. className = 'deep-linking-dial-in'
  141. clickableNumbers = { true }
  142. room = { _room } />
  143. </div>
  144. <HideNotificationBarStyle />
  145. </div>
  146. );
  147. }
  148. _onDownloadApp: () => {};
  149. /**
  150. * Handles download app button clicks.
  151. *
  152. * @returns {void}
  153. */
  154. _onDownloadApp() {
  155. sendAnalytics(
  156. createDeepLinkingPageEvent(
  157. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  158. }
  159. _onOpenApp: () => {};
  160. /**
  161. * Handles open app button clicks.
  162. *
  163. * @returns {void}
  164. */
  165. _onOpenApp() {
  166. sendAnalytics(
  167. createDeepLinkingPageEvent(
  168. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  169. }
  170. }
  171. /**
  172. * Maps (parts of) the Redux state to the associated props for the
  173. * {@code DeepLinkingMobilePage} component.
  174. *
  175. * @param {Object} state - The Redux state.
  176. * @private
  177. * @returns {{
  178. * _room: string
  179. * }}
  180. */
  181. function _mapStateToProps(state) {
  182. return {
  183. _room: state['features/base/conference'].room
  184. };
  185. }
  186. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));