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.

UnsupportedMobileBrowser.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* @flow */
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { translate, translateToHTML } from '../../base/i18n';
  6. import { Platform } from '../../base/react';
  7. import HideNotificationBarStyle from './HideNotificationBarStyle';
  8. /**
  9. * The namespace of the CSS styles of UnsupportedMobileBrowser.
  10. *
  11. * @private
  12. * @type {string}
  13. */
  14. const _SNS = 'unsupported-mobile-browser';
  15. /**
  16. * The namespace of the i18n/translation keys of UnsupportedMobileBrowser.
  17. *
  18. * @private
  19. * @type {string}
  20. */
  21. const _TNS = 'unsupportedBrowser';
  22. /**
  23. * The map of platforms to URLs at which the mobile app for the associated
  24. * platform is available for download.
  25. *
  26. * @private
  27. * @type {Array<string>}
  28. */
  29. const _URLS = {
  30. android: 'https://play.google.com/store/apps/details?id=org.jitsi.meet',
  31. ios: 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905'
  32. };
  33. /**
  34. * React component representing mobile browser page.
  35. *
  36. * @class UnsupportedMobileBrowser
  37. */
  38. class UnsupportedMobileBrowser extends Component {
  39. state: Object;
  40. /**
  41. * UnsupportedMobileBrowser component's property types.
  42. *
  43. * @static
  44. */
  45. static propTypes = {
  46. /**
  47. * The name of the conference room to be joined upon clicking the
  48. * respective button.
  49. *
  50. * @private
  51. * @type {string}
  52. */
  53. _room: PropTypes.string,
  54. /**
  55. * The function to translate human-readable text.
  56. *
  57. * @public
  58. * @type {Function}
  59. */
  60. t: PropTypes.func
  61. };
  62. /**
  63. * Initializes the text and URL of the `Start a conference` / `Join the
  64. * conversation` button which takes the user to the mobile app.
  65. *
  66. * @inheritdoc
  67. */
  68. componentWillMount() {
  69. const joinText
  70. = this.props._room ? 'joinConversation' : 'startConference';
  71. // If the user installed the app while this Component was displayed
  72. // (e.g. the user clicked the Download the App button), then we would
  73. // like to open the current URL in the mobile app. The only way to do it
  74. // appears to be a link with an app-specific scheme, not a Universal
  75. // Link.
  76. const joinURL = `org.jitsi.meet:${window.location.href}`;
  77. this.setState({
  78. joinText,
  79. joinURL
  80. });
  81. }
  82. /**
  83. * Implements React's {@link Component#render()}.
  84. *
  85. * @inheritdoc
  86. * @returns {ReactElement}
  87. */
  88. render() {
  89. const { t } = this.props;
  90. const downloadButtonClassName
  91. = `${_SNS}__button ${_SNS}__button_primary`;
  92. return (
  93. <div className = { _SNS }>
  94. <div className = { `${_SNS}__body` }>
  95. <img
  96. className = { `${_SNS}__logo` }
  97. src = 'images/logo-blue.svg' />
  98. <p className = { `${_SNS}__text` }>
  99. {
  100. translateToHTML(
  101. t,
  102. `${_TNS}.appNotInstalled`,
  103. { postProcess: 'resolveAppName' })
  104. }
  105. </p>
  106. <a href = { _URLS[Platform.OS] }>
  107. <button className = { downloadButtonClassName }>
  108. { t(`${_TNS}.downloadApp`) }
  109. </button>
  110. </a>
  111. <p className = { `${_SNS}__text ${_SNS}__text_small` }>
  112. { translateToHTML(t, `${_TNS}.appInstalled`) }
  113. </p>
  114. <a href = { this.state.joinURL }>
  115. <button className = { `${_SNS}__button` }>
  116. { t(`${_TNS}.${this.state.joinText}`) }
  117. </button>
  118. </a>
  119. </div>
  120. <HideNotificationBarStyle />
  121. </div>
  122. );
  123. }
  124. }
  125. /**
  126. * Maps (parts of) the Redux state to the associated UnsupportedMobileBrowser's
  127. * props.
  128. *
  129. * @param {Object} state - Redux state.
  130. * @private
  131. * @returns {{
  132. * _room: string
  133. * }}
  134. */
  135. function _mapStateToProps(state) {
  136. return {
  137. /**
  138. * The name of the conference room to be joined upon clicking the
  139. * respective button.
  140. *
  141. * @private
  142. * @type {string}
  143. */
  144. _room: state['features/base/conference'].room
  145. };
  146. }
  147. export default translate(connect(_mapStateToProps)(UnsupportedMobileBrowser));