2024-07-10 20:25:35 +03:00
|
|
|
import { Button } from "@/components/ui/button";
|
2024-07-10 21:17:36 +03:00
|
|
|
import { useFirebaseApp, useFirebaseMessaging } from "@/hooks/use-firebase";
|
|
|
|
|
import { getToken } from "firebase/messaging";
|
2024-07-10 20:25:35 +03:00
|
|
|
|
|
|
|
|
export default function NotificationView() {
|
2024-07-10 21:17:36 +03:00
|
|
|
useFirebaseApp();
|
|
|
|
|
const firebaseMessaging = useFirebaseMessaging();
|
2024-07-10 20:25:35 +03:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex size-full flex-col md:flex-row">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => {
|
2024-07-10 21:17:36 +03:00
|
|
|
Notification.requestPermission().then((permission) => {
|
|
|
|
|
if (permission === "granted") {
|
|
|
|
|
getToken(firebaseMessaging, {
|
|
|
|
|
vapidKey:
|
|
|
|
|
"BDd7XT7ElEhLApcxFvrBEs1H-6kfbmjTXhfxRIOXSWUIXOpffl_rlKHOe-qPjzp8Gyqv6tgrWX9-xwSTt2ImKPM",
|
|
|
|
|
}).then((token) => console.log(`the token is ${token}`));
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-07-10 20:25:35 +03:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Enable Notifications
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|