diff --git a/public/.well-known/apple-app-site-association b/public/.well-known/apple-app-site-association new file mode 100644 index 00000000..26d26465 --- /dev/null +++ b/public/.well-known/apple-app-site-association @@ -0,0 +1,12 @@ +{ + "applinks": { + "apps": [], + "details": [ + { + "appID": "87D52NF2QC.com.nthumods.courseweb", + "paths": ["*"] + } + ] + } +} + diff --git a/src/app/[lang]/layout.tsx b/src/app/[lang]/layout.tsx index c0f6df76..dfdc6672 100644 --- a/src/app/[lang]/layout.tsx +++ b/src/app/[lang]/layout.tsx @@ -15,6 +15,7 @@ import { Toaster } from '@/components/ui/toaster'; import ReactQuery from '@/components/ReactQuery'; import './globals.css' +import AppUrlListener from '@/components/AppUrlListener'; export const metadata: Metadata = { title: { @@ -120,6 +121,7 @@ export default function RootLayout({ {children} + diff --git a/src/components/AppUrlListener.tsx b/src/components/AppUrlListener.tsx new file mode 100644 index 00000000..779e09ac --- /dev/null +++ b/src/components/AppUrlListener.tsx @@ -0,0 +1,24 @@ +'use client'; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; +import { App, URLOpenListenerEvent } from '@capacitor/app'; + +const AppUrlListener: React.FC = () => { + const router = useRouter(); + useEffect(() => { + App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => { + // Example url: https://beerswift.app/tabs/tab2 + // slug = /tabs/tab2 + const slug = event.url.split('.app').pop(); + if (slug) { + router.push(slug); + } + }); + }, []); + + return <>; + }; + + export default AppUrlListener; + + \ No newline at end of file