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 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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_orig() {
  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. render() {
  143. const { _room, t } = this.props;
  144. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  145. const downloadButtonClassName
  146. = `${_SNS}__button ${_SNS}__button_primary`;
  147. const onOpenLinkProperties = _URLS[Platform.OS]
  148. ? {
  149. // When opening a link to the download page, we want to let the
  150. // OS itself handle intercepting and opening the appropriate
  151. // app store. This avoids potential issues with browsers, such
  152. // as iOS Chrome, not opening the store properly.
  153. }
  154. : {
  155. // When falling back to another URL (Firebase) let the page be
  156. // opened in a new window. This helps prevent the user getting
  157. // trapped in an app-open-cycle where going back to the mobile
  158. // browser re-triggers the app-open behavior.
  159. target: '_blank',
  160. rel: 'noopener noreferrer'
  161. };
  162. return (
  163. <div className = { _SNS }>
  164. <div className = 'header'>
  165. {/*
  166. <img
  167. className = 'logo'
  168. src = 'images/logo-deep-linking.png' />
  169. */}
  170. </div>
  171. <div className = { `${_SNS}__body` }>
  172. {
  173. SHOW_DEEP_LINKING_IMAGE
  174. ? <img
  175. className = 'image'
  176. src = 'images/deep-linking-image.png' />
  177. : null
  178. }
  179. <p className = { `${_SNS}__text` }>
  180. { t(`${_TNS}.appNotInstalled`, { app: NATIVE_APP_NAME }) }
  181. Mobile browsers are not yet supported.
  182. </p>
  183. <a
  184. { ...onOpenLinkProperties }
  185. href = { this._generateDownloadURL() }
  186. onClick = { this._onDownloadApp }>
  187. <button className = { downloadButtonClassName }>
  188. { t(`${_TNS}.downloadApp`) }
  189. </button>
  190. </a>
  191. <a
  192. { ...onOpenLinkProperties }
  193. className = { `${_SNS}__href` }
  194. href = { generateDeepLinkingURL() }
  195. onClick = { this._onOpenApp }>
  196. {/* <button className = { `${_SNS}__button` }> */}
  197. { t(`${_TNS}.openApp`) }
  198. {/* </button> */}
  199. </a>
  200. { renderPromotionalFooter() }
  201. <DialInSummary
  202. className = 'deep-linking-dial-in'
  203. clickableNumbers = { true }
  204. room = { _room } />
  205. </div>
  206. </div>
  207. );
  208. }
  209. /**
  210. * Generates the URL for downloading the app.
  211. *
  212. * @private
  213. * @returns {string} - The URL for downloading the app.
  214. */
  215. _generateDownloadURL() {
  216. const url = _URLS[Platform.OS];
  217. if (url) {
  218. return url;
  219. }
  220. // For information about the properties of
  221. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  222. // https://firebase.google.com/docs/dynamic-links/create-manually
  223. const {
  224. APN = 'org.jitsi.meet',
  225. APP_CODE = 'w2atb',
  226. IBI = 'com.atlassian.JitsiMeet.ios',
  227. ISI = '1165103905'
  228. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  229. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  230. return `https://${APP_CODE}.app.goo.gl/?link=${
  231. encodeURIComponent(window.location.href)}&apn=${
  232. APN}&ibi=${
  233. IBI}&isi=${
  234. ISI}&ius=${
  235. IUS}&efr=1`;
  236. }
  237. _onDownloadApp: () => void;
  238. /**
  239. * Handles download app button clicks.
  240. *
  241. * @private
  242. * @returns {void}
  243. */
  244. _onDownloadApp() {
  245. sendAnalytics(
  246. createDeepLinkingPageEvent(
  247. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  248. }
  249. _onOpenApp: () => void;
  250. /**
  251. * Handles open app button clicks.
  252. *
  253. * @private
  254. * @returns {void}
  255. */
  256. _onOpenApp() {
  257. sendAnalytics(
  258. createDeepLinkingPageEvent(
  259. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  260. }
  261. }
  262. /**
  263. * Maps (parts of) the Redux state to the associated props for the
  264. * {@code DeepLinkingMobilePage} component.
  265. *
  266. * @param {Object} state - The Redux state.
  267. * @private
  268. * @returns {{
  269. * _room: string
  270. * }}
  271. */
  272. function _mapStateToProps(state) {
  273. return {
  274. _room: decodeURIComponent(state['features/base/conference'].room)
  275. };
  276. }
  277. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));