Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* global interfaceConfig */
  2. import { isMobileBrowser } from '../base/environment/utils';
  3. import { Platform } from '../base/react';
  4. import { URI_PROTOCOL_PATTERN } from '../base/util';
  5. import { isVpaasMeeting } from '../jaas/functions';
  6. import {
  7. DeepLinkingDesktopPage,
  8. DeepLinkingMobilePage,
  9. NoMobileApp
  10. } from './components';
  11. import { _openDesktopApp } from './openDesktopApp';
  12. /**
  13. * Generates a deep linking URL based on the current window URL.
  14. *
  15. * @param {Object} state - Object containing current redux state.
  16. *
  17. * @returns {string} - The generated URL.
  18. */
  19. export function generateDeepLinkingURL(state) {
  20. // If the user installed the app while this Component was displayed
  21. // (e.g. the user clicked the Download the App button), then we would
  22. // like to open the current URL in the mobile app. The only way to do it
  23. // appears to be a link with an app-specific scheme, not a Universal
  24. // Link.
  25. const { href } = window.location;
  26. const regex = new RegExp(URI_PROTOCOL_PATTERN, 'gi');
  27. const mobileConfig = state['features/base/config'].deeplinking?.[Platform.OS] || {};
  28. const { appScheme, appPackage } = mobileConfig;
  29. // Android: use an intent link, custom schemes don't work in all browsers.
  30. // https://developer.chrome.com/multidevice/android/intents
  31. if (Platform.OS === 'android') {
  32. // https://meet.jit.si/foo -> meet.jit.si/foo
  33. const url = href.replace(regex, '').substr(2);
  34. return `intent://${url}#Intent;scheme=${appScheme};package=${appPackage};end`;
  35. }
  36. // iOS: Replace the protocol part with the app scheme.
  37. return href.replace(regex, `${appScheme}:`);
  38. }
  39. /**
  40. * Resolves with the component that should be displayed if the deep linking page
  41. * should be shown and with <tt>undefined</tt> otherwise.
  42. *
  43. * @param {Object} state - Object containing current redux state.
  44. * @returns {Promise<Component>}
  45. */
  46. export function getDeepLinkingPage(state) {
  47. const { room } = state['features/base/conference'];
  48. const { launchInWeb } = state['features/deep-linking'];
  49. const deeplinking = state['features/base/config'].deeplinking || {};
  50. const { appScheme } = deeplinking?.[Platform.OS] || {};
  51. // Show only if we are about to join a conference.
  52. if (launchInWeb
  53. || !room
  54. || state['features/base/config'].deeplinking?.disabled
  55. || (isVpaasMeeting(state) && (!appScheme || appScheme === 'com.8x8.meet'))) {
  56. return Promise.resolve();
  57. }
  58. if (isMobileBrowser()) { // mobile
  59. const mobileAppPromo
  60. = typeof interfaceConfig === 'object'
  61. && interfaceConfig.MOBILE_APP_PROMO;
  62. return Promise.resolve(
  63. typeof mobileAppPromo === 'undefined' || Boolean(mobileAppPromo)
  64. ? DeepLinkingMobilePage : NoMobileApp);
  65. }
  66. return _openDesktopApp(state).then(
  67. // eslint-disable-next-line no-confusing-arrow
  68. result => result ? DeepLinkingDesktopPage : undefined);
  69. }
  70. /**
  71. * Opens the desktop app.
  72. *
  73. * @param {Object} state - Object containing current redux state.
  74. * @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
  75. * with false otherwise.
  76. */
  77. export function openDesktopApp(state) {
  78. return _openDesktopApp(state);
  79. }