您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DeepLinkingMobilePage.web.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from '../../base/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. * 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. {
  99. translateToHTML(
  100. t,
  101. `${_TNS}.appNotInstalled`,
  102. { app: NATIVE_APP_NAME })
  103. }
  104. </p>
  105. <a
  106. href = { this._generateDownloadURL() }
  107. onClick = { this._onDownloadApp }
  108. rel = 'noopener noreferrer'
  109. target = '_blank'>
  110. <button className = { downloadButtonClassName }>
  111. { t(`${_TNS}.downloadApp`) }
  112. </button>
  113. </a>
  114. <a
  115. className = { `${_SNS}__href` }
  116. href = { generateDeepLinkingURL() }
  117. onClick = { this._onOpenApp }
  118. rel = 'noopener noreferrer'
  119. target = '_blank'>
  120. {/* <button className = { `${_SNS}__button` }> */}
  121. { t(`${_TNS}.openApp`) }
  122. {/* </button> */}
  123. </a>
  124. <DialInSummary
  125. className = 'deep-linking-dial-in'
  126. clickableNumbers = { true }
  127. room = { _room } />
  128. </div>
  129. </div>
  130. );
  131. }
  132. /**
  133. * Generates the URL for downloading the app.
  134. *
  135. * @private
  136. * @returns {string} - The URL for downloading the app.
  137. */
  138. _generateDownloadURL() {
  139. const url = _URLS[Platform.OS];
  140. if (url) {
  141. return url;
  142. }
  143. // For information about the properties of
  144. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  145. // https://firebase.google.com/docs/dynamic-links/create-manually
  146. const {
  147. APN = 'org.jitsi.meet',
  148. APP_CODE = 'w2atb',
  149. IBI = 'com.atlassian.JitsiMeet.ios',
  150. ISI = '1165103905'
  151. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  152. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  153. return `https://${APP_CODE}.app.goo.gl/?link=${
  154. encodeURIComponent(window.location.href)}&apn=${
  155. APN}&ibi=${
  156. IBI}&isi=${
  157. ISI}&ius=${
  158. IUS}&efr=1`;
  159. }
  160. _onDownloadApp: () => {};
  161. /**
  162. * Handles download app button clicks.
  163. *
  164. * @private
  165. * @returns {void}
  166. */
  167. _onDownloadApp() {
  168. sendAnalytics(
  169. createDeepLinkingPageEvent(
  170. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  171. }
  172. _onOpenApp: () => {};
  173. /**
  174. * Handles open app button clicks.
  175. *
  176. * @private
  177. * @returns {void}
  178. */
  179. _onOpenApp() {
  180. sendAnalytics(
  181. createDeepLinkingPageEvent(
  182. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  183. }
  184. }
  185. /**
  186. * Maps (parts of) the Redux state to the associated props for the
  187. * {@code DeepLinkingMobilePage} component.
  188. *
  189. * @param {Object} state - The Redux state.
  190. * @private
  191. * @returns {{
  192. * _room: string
  193. * }}
  194. */
  195. function _mapStateToProps(state) {
  196. return {
  197. _room: decodeURIComponent(state['features/base/conference'].room)
  198. };
  199. }
  200. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));