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

DeepLinkingMobilePage.web.js 7.0KB

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