fix: Request notification permission on room join
Request push notification permission automatically when joining a room, similar to how location permission is requested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4f110a7604
commit
b8adffc4ad
|
|
@ -148,15 +148,17 @@ export default function RoomPage() {
|
|||
roomSlug: slug,
|
||||
});
|
||||
|
||||
// Auto-subscribe to push when location sharing starts
|
||||
// Auto-subscribe to push when joining room (like location permission)
|
||||
const hasRequestedPushRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (isSharing && !isPushSubscribed && syncUrl) {
|
||||
console.log('Auto-subscribing to push notifications for background pings');
|
||||
if (isConnected && !isPushSubscribed && !hasRequestedPushRef.current && syncUrl) {
|
||||
hasRequestedPushRef.current = true;
|
||||
console.log('Auto-requesting push notification permission');
|
||||
subscribePush().catch((err) => {
|
||||
console.warn('Push subscription failed (user may have denied):', err.message);
|
||||
});
|
||||
}
|
||||
}, [isSharing, isPushSubscribed, subscribePush, syncUrl]);
|
||||
}, [isConnected, isPushSubscribed, subscribePush, syncUrl]);
|
||||
|
||||
// Restore last known location immediately when connected
|
||||
const hasRestoredLocationRef = useRef(false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue