auto trigger game actions
This commit is contained in:
@@ -276,21 +276,19 @@ export function handleFlicAction(action, buttonId, timestamp, batteryLevel) {
|
||||
export function initPushFlic(handlers) {
|
||||
actionHandlers = handlers; // Store the handlers passed from app.js
|
||||
|
||||
// Don't auto-subscribe - wait for user action
|
||||
// This prevents issues with permission/notification prompts appearing unexpectedly
|
||||
|
||||
// Auto-subscribe when permission is granted
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
// Check if permission is already granted, but don't automatically subscribe
|
||||
if (Notification.permission === 'granted') {
|
||||
console.log('[PushFlic] Permission already granted, but waiting for user action to subscribe.');
|
||||
// Check if we have valid credentials
|
||||
const hasCredentials = !!getBasicAuthCredentials();
|
||||
console.log('[PushFlic] Has stored credentials:', hasCredentials);
|
||||
Notification.requestPermission().then(permission => {
|
||||
if (permission === 'granted') {
|
||||
console.log('[PushFlic] Permission granted, attempting subscription.');
|
||||
subscribeToPush();
|
||||
} else {
|
||||
console.log('[PushFlic] Notification permission not granted yet.');
|
||||
console.log('[PushFlic] Notification permission not granted.');
|
||||
// Optionally provide a button for the user to trigger subscription later
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user