This commit is contained in:
cpu
2025-03-28 05:50:28 +01:00
parent d1ad962ec3
commit 2e47461f34
5 changed files with 15 additions and 306 deletions

View File

@@ -9,14 +9,6 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<link rel="stylesheet" href="styles.css">
<!-- Deep Linking - App Links for Android -->
<link rel="alternate" href="android-app://eu.virtonline.gametimer/https://game-timer.virtonline.eu" />
<!-- Deep Linking - Universal Links for iOS -->
<meta name="apple-itunes-app" content="app-id=yourAppID, app-argument=https://game-timer.virtonline.eu">
<!-- Deep Linking - Web App URL Handling -->
<link rel="alternate" href="web+gametimer://action" />
</head>
<body>
<div class="app-container">
@@ -108,53 +100,7 @@
<button id="cameraCaptureButton" class="camera-button-large"></button>
</div>
</div>
<!-- Script for handling URL scheme and deep links -->
<script type="module">
// Register the custom URL protocol handler (web+gametimer://)
if ('registerProtocolHandler' in navigator) {
try {
navigator.registerProtocolHandler(
'web+gametimer',
'https://game-timer.virtonline.eu/?action=%s',
'Game Timer'
);
console.log('Protocol handler registered');
} catch (e) {
console.error('Failed to register protocol handler:', e);
}
}
// Function to parse URL parameters
function getUrlParams() {
const searchParams = new URLSearchParams(window.location.search);
const hashParams = new URLSearchParams(window.location.hash.substring(1));
// Check search parameters first (for direct links)
const action = searchParams.get('action');
if (action) {
// Clean the action parameter (remove 'web+gametimer://' if present)
return action.replace('web+gametimer://', '');
}
// Then check hash parameters (for deep links)
return hashParams.get('action');
}
// Initialize URL handling
function initUrlHandling() {
const action = getUrlParams();
if (action) {
console.log('URL action detected:', action);
// Set the action in the hash to be processed by the main app
window.location.hash = `action=${action}`;
}
}
// Run initialization when DOM is fully loaded
document.addEventListener('DOMContentLoaded', initUrlHandling);
</script>
<!-- Main application script -->
<script type="module" src="app.js"></script>
<script>