custom URL schema handling

This commit is contained in:
Nuwan 2024-10-25 17:08:28 +05:30
parent a5fce73848
commit fd8f31e7d4
2 changed files with 20 additions and 19 deletions

View File

@ -377,12 +377,12 @@
try {
const url = new URL(loggedInResp);
const redirectTo = new URLSearchParams(url.search).get("redirect-to");
console.log("_DEBUG_ handleLoggedInResponse redirecting to", loggedInResp);
console.log("** handleLoggedInResponse redirecting to", loggedInResp);
if (redirectTo) {
window.location.href = redirectTo;
}
} catch (e) {
console.log("error in handleLoggedInResponse", e);
console.log("** error in handleLoggedInResponse", e);
}
}

View File

@ -459,27 +459,28 @@
// this is a hack to create a session from a custom URL scheme
// an example custom URL would be: https://www.jamkazam.com/client#/createSession/custom~yes|privacy~2|description~hello|inviteeIds~1,2,3,4
var hash = decodeURIComponent(window.location.hash)
console.log("** handleCustomUrlScheme hash **", hash);
if(hash === '' || !hash.includes("custom~yes")){ // if there is no hash or the hash does not contain custom~yes,
return;
}
var maxAttempts = 10;
var screenLoadInterval = setInterval(() => {
if(hash.includes("#/createSession")){
if (JK.createScheduledSessionScreen) {
JK.createScheduledSessionScreen.createSessionByCustomUrlScheme(hash); // this will create a session
clearInterval(screenLoadInterval);
}else{
console.log("** attempting to create session by custom URL scheme", maxAttempts);
maxAttempts--;
if(maxAttempts <= 0){
var hash = decodeURIComponent(window.location.hash)
console.log("** handleCustomUrlScheme hash **", hash);
if(hash.includes("custom~yes")){ // if the hash contains the custom yes flag
if(hash.includes("#/createSession")){ // if the hash contains the createSession flag
if (JK.createScheduledSessionScreen) {
JK.createScheduledSessionScreen.createSessionByCustomUrlScheme(hash); // this will create a session
clearInterval(screenLoadInterval);
}
}else{
console.log("** attempting to create session by custom URL scheme", maxAttempts);
maxAttempts--;
if(maxAttempts <= 0){
clearInterval(screenLoadInterval);
}
}
}
}
}, 1000); // check every second