debug: add notification debug component to troubleshoot iOS
This commit is contained in:
@@ -3,6 +3,7 @@ import './globals.css'
|
||||
import ServiceWorkerRegistration from '@/components/ServiceWorkerRegistration'
|
||||
import OfflineIndicator from '@/components/OfflineIndicator'
|
||||
import NotificationPrompt from '@/components/NotificationPrompt'
|
||||
import NotificationDebug from '@/components/NotificationDebug'
|
||||
import { ToastProvider } from '@/components/ToastContainer'
|
||||
import ErrorBoundary from '@/components/ErrorBoundary'
|
||||
|
||||
@@ -77,6 +78,7 @@ export default function RootLayout({
|
||||
<ServiceWorkerRegistration />
|
||||
<OfflineIndicator />
|
||||
<NotificationPrompt />
|
||||
<NotificationDebug />
|
||||
{children}
|
||||
</ToastProvider>
|
||||
</ErrorBoundary>
|
||||
|
||||
29
components/NotificationDebug.tsx
Normal file
29
components/NotificationDebug.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export default function NotificationDebug() {
|
||||
const [debug, setDebug] = useState<any>({});
|
||||
|
||||
useEffect(() => {
|
||||
const info = {
|
||||
notificationSupported: 'Notification' in window,
|
||||
serviceWorkerSupported: 'serviceWorker' in navigator,
|
||||
pushManagerSupported: 'PushManager' in window,
|
||||
permission: 'Notification' in window ? Notification.permission : 'N/A',
|
||||
localStorage: typeof localStorage !== 'undefined' ? localStorage.getItem('notification-prompt-dismissed') : 'N/A',
|
||||
};
|
||||
setDebug(info);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="fixed bottom-4 left-4 bg-black text-white text-xs p-3 rounded-lg max-w-xs z-50 font-mono">
|
||||
<div className="font-bold mb-2">Push Debug:</div>
|
||||
<div>Notification: {debug.notificationSupported ? '✓' : '✗'}</div>
|
||||
<div>ServiceWorker: {debug.serviceWorkerSupported ? '✓' : '✗'}</div>
|
||||
<div>PushManager: {debug.pushManagerSupported ? '✓' : '✗'}</div>
|
||||
<div>Permission: {debug.permission}</div>
|
||||
<div>Dismissed: {debug.localStorage || 'No'}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user