Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DeepLinkingMobilePage.web.js 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. // @flow
  2. import React, { Component } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { createDeepLinkingPageEvent, sendAnalytics } from '../../analytics';
  5. import { IDeeplinkingConfig, IDeeplinkingMobileConfig } from '../../base/config/configType';
  6. import { isSupportedMobileBrowser } from '../../base/environment';
  7. import { translate } from '../../base/i18n';
  8. import { Platform } from '../../base/react';
  9. import { connect } from '../../base/redux';
  10. import { DialInSummary } from '../../invite';
  11. import { openWebApp } from '../actions';
  12. import { _TNS } from '../constants';
  13. import { generateDeepLinkingURL } from '../functions';
  14. import { renderPromotionalFooter } from '../renderPromotionalFooter';
  15. /**
  16. * The namespace of the CSS styles of DeepLinkingMobilePage.
  17. *
  18. * @private
  19. * @type {string}
  20. */
  21. const _SNS = 'deep-linking-mobile';
  22. /**
  23. * The type of the React {@code Component} props of
  24. * {@link DeepLinkingMobilePage}.
  25. */
  26. type Props = {
  27. /**
  28. * The deeplinking config.
  29. */
  30. _deeplinkingCfg: IDeeplinkingConfig,
  31. /**
  32. * Application mobile deeplinking config.
  33. */
  34. _mobileConfig: IDeeplinkingMobileConfig,
  35. /**
  36. * The deeplinking url.
  37. */
  38. _deepLinkingUrl: string,
  39. /**
  40. * The name of the conference attempting to being joined.
  41. */
  42. _room: string,
  43. /**
  44. * The page current url.
  45. */
  46. _url: URL,
  47. /**
  48. * Used to dispatch actions from the buttons.
  49. */
  50. dispatch: Dispatch<any>,
  51. /**
  52. * The function to translate human-readable text.
  53. */
  54. t: Function
  55. };
  56. /**
  57. * React component representing mobile browser page.
  58. *
  59. * @class DeepLinkingMobilePage
  60. */
  61. class DeepLinkingMobilePage extends Component<Props> {
  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. // Bind event handlers so they are only bound once per instance.
  71. this._onDownloadApp = this._onDownloadApp.bind(this);
  72. this._onLaunchWeb = this._onLaunchWeb.bind(this);
  73. this._onOpenApp = this._onOpenApp.bind(this);
  74. }
  75. /**
  76. * Implements the Component's componentDidMount method.
  77. *
  78. * @inheritdoc
  79. */
  80. componentDidMount() {
  81. sendAnalytics(
  82. createDeepLinkingPageEvent(
  83. 'displayed', 'DeepLinkingMobile', { isMobileBrowser: true }));
  84. }
  85. /**
  86. * Implements React's {@link Component#render()}.
  87. *
  88. * @inheritdoc
  89. * @returns {ReactElement}
  90. */
  91. render() {
  92. const {
  93. _deeplinkingCfg: { hideLogo },
  94. _mobileConfig: { downloadLink, appName },
  95. _room,
  96. t,
  97. _url,
  98. _deepLinkingUrl
  99. } = this.props;
  100. const downloadButtonClassName
  101. = `${_SNS}__button ${_SNS}__button_primary`;
  102. const onOpenLinkProperties = downloadLink
  103. ? {
  104. // When opening a link to the download page, we want to let the
  105. // OS itself handle intercepting and opening the appropriate
  106. // app store. This avoids potential issues with browsers, such
  107. // as iOS Chrome, not opening the store properly.
  108. }
  109. : {
  110. // When falling back to another URL (Firebase) let the page be
  111. // opened in a new window. This helps prevent the user getting
  112. // trapped in an app-open-cycle where going back to the mobile
  113. // browser re-triggers the app-open behavior.
  114. target: '_blank',
  115. rel: 'noopener noreferrer'
  116. };
  117. return (
  118. <div className = { _SNS }>
  119. <div className = 'header'>
  120. {
  121. hideLogo
  122. ? null
  123. : <img
  124. alt = { t('welcomepage.logo.logoDeepLinking') }
  125. className = 'logo'
  126. src = 'images/logo-deep-linking.png' />
  127. }
  128. </div>
  129. <div className = { `${_SNS}__body` }>
  130. <p className = { `${_SNS}__text` }>
  131. { t(`${_TNS}.appNotInstalled`, { app: appName }) }
  132. </p>
  133. <p className = { `${_SNS}__text` }>
  134. { t(`${_TNS}.ifHaveApp`) }
  135. </p>
  136. <a
  137. { ...onOpenLinkProperties }
  138. className = { `${_SNS}__href` }
  139. href = { _deepLinkingUrl }
  140. onClick = { this._onOpenApp }
  141. target = '_top'>
  142. <button className = { `${_SNS}__button ${_SNS}__button_primary` }>
  143. { t(`${_TNS}.joinInApp`) }
  144. </button>
  145. </a>
  146. <p className = { `${_SNS}__text` }>
  147. { t(`${_TNS}.ifDoNotHaveApp`) }
  148. </p>
  149. <a
  150. { ...onOpenLinkProperties }
  151. href = { this._generateDownloadURL() }
  152. onClick = { this._onDownloadApp }
  153. target = '_top'>
  154. <button className = { downloadButtonClassName }>
  155. { t(`${_TNS}.downloadApp`) }
  156. </button>
  157. </a>
  158. {
  159. isSupportedMobileBrowser()
  160. ? (
  161. <a
  162. onClick = { this._onLaunchWeb }
  163. target = '_top'>
  164. <button className = { downloadButtonClassName }>
  165. { t(`${_TNS}.launchWebButton`) }
  166. </button>
  167. </a>
  168. ) : (
  169. <b>
  170. { t(`${_TNS}.unsupportedBrowser`) }
  171. </b>
  172. )
  173. }
  174. { renderPromotionalFooter() }
  175. <DialInSummary
  176. className = 'deep-linking-dial-in'
  177. clickableNumbers = { true }
  178. room = { _room }
  179. url = { _url } />
  180. </div>
  181. </div>
  182. );
  183. }
  184. /**
  185. * Generates the URL for downloading the app.
  186. *
  187. * @private
  188. * @returns {string} - The URL for downloading the app.
  189. */
  190. _generateDownloadURL() {
  191. const { _mobileConfig: { downloadLink, dynamicLink, appScheme } } = this.props;
  192. if (downloadLink && typeof dynamicLink === 'undefined') {
  193. return downloadLink;
  194. }
  195. const {
  196. apn,
  197. appCode,
  198. customDomain,
  199. ibi,
  200. isi
  201. } = dynamicLink || {};
  202. const domain = customDomain ?? `https://${appCode}.app.goo.gl`;
  203. return `${domain}/?link=${
  204. encodeURIComponent(window.location.href)}&apn=${
  205. apn}&ibi=${
  206. ibi}&isi=${
  207. isi}&ius=${
  208. appScheme}&efr=1`;
  209. }
  210. _onDownloadApp: () => void;
  211. /**
  212. * Handles download app button clicks.
  213. *
  214. * @private
  215. * @returns {void}
  216. */
  217. _onDownloadApp() {
  218. sendAnalytics(
  219. createDeepLinkingPageEvent(
  220. 'clicked', 'downloadAppButton', { isMobileBrowser: true }));
  221. }
  222. _onLaunchWeb: () => void;
  223. /**
  224. * Handles launch web button clicks.
  225. *
  226. * @returns {void}
  227. */
  228. _onLaunchWeb() {
  229. sendAnalytics(
  230. createDeepLinkingPageEvent(
  231. 'clicked', 'launchWebButton', { isMobileBrowser: true }));
  232. this.props.dispatch(openWebApp());
  233. }
  234. _onOpenApp: () => void;
  235. /**
  236. * Handles open app button clicks.
  237. *
  238. * @private
  239. * @returns {void}
  240. */
  241. _onOpenApp() {
  242. sendAnalytics(
  243. createDeepLinkingPageEvent(
  244. 'clicked', 'openAppButton', { isMobileBrowser: true }));
  245. }
  246. }
  247. /**
  248. * Maps (parts of) the Redux state to the associated props for the
  249. * {@code DeepLinkingMobilePage} component.
  250. *
  251. * @param {Object} state - The Redux state.
  252. * @private
  253. * @returns {Props}
  254. */
  255. function _mapStateToProps(state) {
  256. const { locationURL = {} } = state['features/base/connection'];
  257. const { deeplinking } = state['features/base/config'];
  258. const mobileConfig = deeplinking?.[Platform.OS] || {};
  259. return {
  260. _deeplinkingCfg: deeplinking || {},
  261. _mobileConfig: mobileConfig,
  262. _room: decodeURIComponent(state['features/base/conference'].room),
  263. _url: locationURL,
  264. _deepLinkingUrl: generateDeepLinkingURL(state)
  265. };
  266. }
  267. export default translate(connect(_mapStateToProps)(DeepLinkingMobilePage));