Skip to content

Commit

Permalink
added apple app site assoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew committed Apr 15, 2024
1 parent 3784e5f commit c1be4f6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions public/.well-known/apple-app-site-association
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"applinks": {
"apps": [],
"details": [
{
"appID": "87D52NF2QC.com.nthumods.courseweb",
"paths": ["*"]
}
]
}
}

2 changes: 2 additions & 0 deletions src/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -120,6 +121,7 @@ export default function RootLayout({
<html lang={params.lang} className={`${theme?.value ?? ''} ${inter.variable} ${noto.variable}`} suppressHydrationWarning>
<body>
{children}
<AppUrlListener/>
<Toaster />
</body>
</html>
Expand Down
24 changes: 24 additions & 0 deletions src/components/AppUrlListener.tsx
Original file line number Diff line number Diff line change
@@ -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<any> = () => {
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;


0 comments on commit c1be4f6

Please sign in to comment.