diff --git a/jam-ui/src/components/page/JKAppLaunch.js b/jam-ui/src/components/page/JKAppLaunch.js index 2f66cead2..f66196aea 100644 --- a/jam-ui/src/components/page/JKAppLaunch.js +++ b/jam-ui/src/components/page/JKAppLaunch.js @@ -7,16 +7,20 @@ import FalconCardHeader from '../common/FalconCardHeader'; const JKCustomUrlSchemaHandle = () => { const [urlScheme, setUrlScheme] = useState(null); const { t } = useTranslation(); + useEffect(() => { const queryStr = window.location.search; if (!queryStr) return; - const appUrl = jkCustomUrlScheme('createSession', queryStr); + const urlParams = new URLSearchParams(queryStr); + const action = urlParams.get('act'); + const params = urlParams.get('p'); + const appUrl = jkCustomUrlScheme(action, params); setUrlScheme(appUrl); }, []); useEffect(() => { if (urlScheme) { - console.log('urlScheme', urlScheme); + console.log('opening custom url', urlScheme); window.open(urlScheme, '_self'); } }, [urlScheme]); diff --git a/jam-ui/src/components/page/JKNewMusicSession.js b/jam-ui/src/components/page/JKNewMusicSession.js index c18014c29..43cb6d56d 100644 --- a/jam-ui/src/components/page/JKNewMusicSession.js +++ b/jam-ui/src/components/page/JKNewMusicSession.js @@ -14,12 +14,6 @@ import useNativeAppCheck from '../../hooks/useNativeAppCheck'; import { useNativeApp } from '../../context/NativeAppContext'; import { useResponsive } from '@farfetch/react-context-responsive'; import { sessionPrivacyMap } from '../../config'; -// const privacyMap = { -// public: 1, -// private_invite: 2, -// private_approve: 3 -// }; - const JKNewMusicSession = () => { const { currentUser } = useAuth(); @@ -91,15 +85,11 @@ const JKNewMusicSession = () => { } catch (error) { console.error('localStorage is not available', error); } - //check if jamkazam app is installed try { + //check if jamkazam app is installed await isNativeAppAvailable(); - //window.open jamkazam app url using custom URL scheme - //an example URL would be: jamkazam://url=https://www.jamkazam.com/client#/createSession/privacy~2|description~hello|inviteeIds~1,2,3,4 const q = `privacy~${payload.privacy}|description~${payload.description}|inviteeIds~${payload.inviteeIds}`; - //const urlScheme = jkCustomUrlScheme('createSession', q); - //window.location.href = urlScheme; - history.push(`/applaunch?${q}`); + history.push(`/applaunch?act=createSession&p=${q}`); } catch (error) { toggleAppUnavilableModel(); } diff --git a/jam-ui/src/components/sessions/JKSession.js b/jam-ui/src/components/sessions/JKSession.js index f8924978c..c4ff76cff 100644 --- a/jam-ui/src/components/sessions/JKSession.js +++ b/jam-ui/src/components/sessions/JKSession.js @@ -7,16 +7,14 @@ import { useTranslation } from 'react-i18next'; import { useResponsive } from '@farfetch/react-context-responsive'; import PropTypes from 'prop-types'; import { Row, Col, Button, UncontrolledTooltip } from 'reactstrap'; - import jkCustomUrlScheme from '../../helpers/jkCustomUrlScheme'; - import JKUserLatencyBadge from '../profile/JKUserLatencyBadge'; import JKSessionUser from './JKSessionUser'; import useNativeAppCheck from '../../hooks/useNativeAppCheck'; import { useNativeApp } from '../../context/NativeAppContext'; import EnterIcon from '../../icons/enter.svg'; import JKInstrumentIcon from '../profile/JKInstrumentIcon'; - +import {useHistory} from 'react-router-dom'; import useSessionHelper from './JKUseSessionHelper'; function JKSession({ session }) { @@ -26,6 +24,7 @@ function JKSession({ session }) { const { greaterThan } = useResponsive(); const { setNativeAppUnavailable } = useNativeApp(); const { sessionDescription } = useSessionHelper(session); + const history = useHistory(); useEffect(() => { const otherUserIds = session.participants.map(p => p.user.id); @@ -170,8 +169,7 @@ function JoinSessionButton({ session }) { try { await isNativeAppAvailable(); const q = `sessionId~${session.id}`; - const urlScheme = jkCustomUrlScheme('joinSession', q); - window.document.href = urlScheme; + history.push(`/applaunch?act=joinSession&p=${q}`); return; } catch (error) { setNativeAppUnavailable(true);