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.web.js 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-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. * The type of the React {@code Component} state of
  45. * {@link DeepLinkingMobilePage}.
  46. */
  47. type State = {
  48. /**
  49. * The URL to link to on the button for opening the mobile app.
  50. */
  51. joinURL: string
  52. };
  53. /**
  54. * React component representing mobile browser page.
  55. *
  56. * @class DeepLinkingMobilePage
  57. */
  58. class DeepLinkingMobilePage extends Component<Props, State> {
  59. state = {
  60. joinURL: ''
  61. };
  62. /**
  63. * Initializes a new {@code DeepLinkingMobilePage} instance.
  64. *
  65. * @param {Object} props - The read-only React {@code Component} props with
  66. * which the new instance is to be initialized.
  67. */
  68. constructor(props: Props) {
  69. super(props);
  70. this.state = {
  71. joinURL: generateDeepLinkingURL()
  72. };
  73. // Bind event handlers so they are only bound once per instance.
  74. this._onDownloadApp = this._onDownloadApp.bind(this);
  75. this._onOpenApp = this._onOpenApp.bind(this);
  76. }
  77. /**
  78. * Implements the Component's componentDidMount method.
  79. *
  80. * @inheritdoc
  81. */
  82. componentDidMount() {
  83. sendAnalytics(
  84. createDeepLinkingPageEvent(
  85. 'displayed', 'DeepLinkingMobile', { isMobileBrowser: true }));
  86. }
  87. /**
  88. * Implements React's {@link Component#render()}.
  89. *
  90. * @inheritdoc
  91. * @returns {ReactElement}
  92. */
  93. render() {
  94. const { _room, t } = this.props;
  95. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  96. const downloadButtonClassName
  97. = `${_SNS}__button ${_SNS}__button_primary`;
  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. {
  115. translateToHTML(
  116. t,
  117. `${_TNS}.appNotInstalled`,
  118. { app: NATIVE_APP_NAME })
  119. }
  120. </p>
  121. <a
  122. href = { this._generateDownloadURL() }
  123. onClick = { this._onDownloadApp }
  124. rel = 'noopener noreferrer'
  125. target = '_blank'>
  126. <button className = { downloadButtonClassName }>
  127. { t(`${_TNS}.downloadApp`) }
  128. </button>
  129. </a>
  130. <a
  131. className = { `${_SNS}__href` }
  132. href = { this.state.joinURL }
  133. onClick = { this._onOpenApp }
  134. rel = 'noopener noreferrer'
  135. target = '_blank'>
  136. {/* <button className = { `${_SNS}__button` }> */}
  137. { t(`${_TNS}.openApp`) }
  138. {/* </button> */}
  139. </a>
  140. <DialInSummary
  141. className = 'deep-linking-dial-in'
  142. clickableNumbers = { true }
  143. room = { _room } />
  144. </div>
  145. </div>
  146. );
  147. }
  148. /**
  149. * Generates the URL for downloading the app.
  150. *
  151. * @private
  152. * @returns {string} - The URL for downloading the app.
  153. */
  154. _generateDownloadURL() {
  155. const url = _URLS[Platform.OS];
  156. if (url) {
  157. return url;
  158. }
  159. // For information about the properties of
  160. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  161. // https://firebase.google.com/docs/dynamic-links/create-manually
  162. const {
  163. APN = 'org.jitsi.meet',
  164. APP_CODE = 'w2atb',
  165. IBI = 'com.atlassian.JitsiMeet.ios',
  166. ISI = '1165103905'
  167. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  168. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  169. return `https://${APP_CODE}.app.goo.gl/?link=${
  170. encodeURIComponent(window.location.href)}&apn=${
  171. APN}&ibi=${
  172. IBI}&isi=${
  173. ISI}&ius=${
  174. IUS}&efr=1`;
  175. }
  176. _onDownloadApp: () => {};
  177. /**
  178. * Handles download app button clicks.
  179. *
  180. * @private
  181. * @returns {void}
  182. */
  183. _onDownloadApp() {
  184. sendAnalytics(
  185. createDeepLinkingPageEvent(
  186. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  187. }
  188. _onOpenApp: () => {};
  189. /**
  190. * Handles open app button clicks.
  191. *
  192. * @private
  193. * @returns {void}
  194. */
  195. _onOpenApp() {
  196. sendAnalytics(
  197. createDeepLinkingPageEvent(
  198. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  199. }
  200. }
  201. /**
  202. * Maps (parts of) the Redux state to the associated props for the
  203. * {@code DeepLinkingMobilePage} component.
  204. *
  205. * @param {Object} state - The Redux state.
  206. * @private
  207. * @returns {{
  208. * _room: string
  209. * }}
  210. */
  211. function _mapStateToProps(state) {
  212. return {
  213. _room: state['features/base/conference'].room
  214. };
  215. }
  216. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));