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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. // { t(`${_TNS}.appNotInstalled`, { app: NATIVE_APP_NAME }) }
  163. return (
  164. <div className = { _SNS }>
  165. <div className = 'header'>
  166. {/*
  167. <img
  168. className = 'logo'
  169. src = 'images/logo-deep-linking.png' />
  170. */}
  171. </div>
  172. <div className = { `${_SNS}__body` }>
  173. {
  174. SHOW_DEEP_LINKING_IMAGE
  175. ? <img
  176. className = 'image'
  177. src = 'images/deep-linking-image.png' />
  178. : null
  179. }
  180. <p className = { `${_SNS}__text` }>
  181. Mobile browsers are not yet supported.
  182. Try connecting from a laptop.
  183. </p>
  184. </div>
  185. </div>
  186. );
  187. }
  188. /**
  189. * Generates the URL for downloading the app.
  190. *
  191. * @private
  192. * @returns {string} - The URL for downloading the app.
  193. */
  194. _generateDownloadURL() {
  195. const url = _URLS[Platform.OS];
  196. if (url) {
  197. return url;
  198. }
  199. // For information about the properties of
  200. // interfaceConfig.MOBILE_DYNAMIC_LINK check:
  201. // https://firebase.google.com/docs/dynamic-links/create-manually
  202. const {
  203. APN = 'org.jitsi.meet',
  204. APP_CODE = 'w2atb',
  205. IBI = 'com.atlassian.JitsiMeet.ios',
  206. ISI = '1165103905'
  207. } = interfaceConfig.MOBILE_DYNAMIC_LINK || {};
  208. const IUS = interfaceConfig.APP_SCHEME || 'org.jitsi.meet';
  209. return `https://${APP_CODE}.app.goo.gl/?link=${
  210. encodeURIComponent(window.location.href)}&apn=${
  211. APN}&ibi=${
  212. IBI}&isi=${
  213. ISI}&ius=${
  214. IUS}&efr=1`;
  215. }
  216. _onDownloadApp: () => void;
  217. /**
  218. * Handles download app button clicks.
  219. *
  220. * @private
  221. * @returns {void}
  222. */
  223. _onDownloadApp() {
  224. sendAnalytics(
  225. createDeepLinkingPageEvent(
  226. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  227. }
  228. _onOpenApp: () => void;
  229. /**
  230. * Handles open app button clicks.
  231. *
  232. * @private
  233. * @returns {void}
  234. */
  235. _onOpenApp() {
  236. sendAnalytics(
  237. createDeepLinkingPageEvent(
  238. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  239. }
  240. }
  241. /**
  242. * Maps (parts of) the Redux state to the associated props for the
  243. * {@code DeepLinkingMobilePage} component.
  244. *
  245. * @param {Object} state - The Redux state.
  246. * @private
  247. * @returns {{
  248. * _room: string
  249. * }}
  250. */
  251. function _mapStateToProps(state) {
  252. return {
  253. _room: decodeURIComponent(state['features/base/conference'].room)
  254. };
  255. }
  256. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));