您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.js 2.9KB

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