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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. target = "_blank">
  125. <button className = { downloadButtonClassName }>
  126. { t(`${_TNS}.downloadApp`) }
  127. </button>
  128. </a>
  129. <a
  130. className = { `${_SNS}__href` }
  131. href = { this.state.joinURL }
  132. onClick = { this._onOpenApp }
  133. target = "_blank">
  134. {/* <button className = { `${_SNS}__button` }> */}
  135. { t(`${_TNS}.openApp`) }
  136. {/* </button> */}
  137. </a>
  138. <DialInSummary
  139. className = 'deep-linking-dial-in'
  140. clickableNumbers = { true }
  141. room = { _room } />
  142. </div>
  143. </div>
  144. );
  145. }
  146. /**
  147. * Generates the URL for downloading the app.
  148. *
  149. * @private
  150. * @returns {string} - The URL for downloading the app.
  151. */
  152. _generateDownloadURL() {
  153. const url = _URLS[Platform.OS];
  154. if (url) {
  155. return url;
  156. }
  157. // For information about the properties of
  158. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  159. // https://firebase.google.com/docs/dynamic-links/create-manually
  160. const {
  161. APN = 'org.jitsi.meet',
  162. APP_CODE = 'w2atb',
  163. IBI = 'com.atlassian.JitsiMeet.ios',
  164. ISI = '1165103905'
  165. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  166. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  167. return `https://${APP_CODE}.app.goo.gl/?link=${
  168. encodeURIComponent(window.location.href)}&apn=${
  169. APN}&ibi=${
  170. IBI}&isi=${
  171. ISI}&ius=${
  172. IUS}&efr=1`;
  173. }
  174. _onDownloadApp: () => {};
  175. /**
  176. * Handles download app button clicks.
  177. *
  178. * @private
  179. * @returns {void}
  180. */
  181. _onDownloadApp() {
  182. sendAnalytics(
  183. createDeepLinkingPageEvent(
  184. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  185. }
  186. _onOpenApp: () => {};
  187. /**
  188. * Handles open app button clicks.
  189. *
  190. * @private
  191. * @returns {void}
  192. */
  193. _onOpenApp() {
  194. sendAnalytics(
  195. createDeepLinkingPageEvent(
  196. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  197. }
  198. }
  199. /**
  200. * Maps (parts of) the Redux state to the associated props for the
  201. * {@code DeepLinkingMobilePage} component.
  202. *
  203. * @param {Object} state - The Redux state.
  204. * @private
  205. * @returns {{
  206. * _room: string
  207. * }}
  208. */
  209. function _mapStateToProps(state) {
  210. return {
  211. _room: state['features/base/conference'].room
  212. };
  213. }
  214. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));