🔧 PWA Troubleshooting - Tools Artes do Sul
✅ Correções Implementadas
1. Arquivos Criados
- ✅
manifest-tools.json- Manifest para o site principal - ✅
sw-tools.js- Service Worker para o site principal - ✅
diagnostico-pwa.html- Ferramenta de diagnóstico - ✅ Referências PWA adicionadas no
index.html
2. Configurações no index.html
- ✅
<link rel="manifest" href="/manifest-tools.json"> - ✅ Meta tags:
theme-color,description - ✅ Ícones:
apple-touch-icon,favicon - ✅ Código de registro do Service Worker
- ✅ Handler para
beforeinstallprompt
🚨 Problemas Comuns e Soluções
Problema: PWA não ativa / Manifest não encontrado
Verificações:
- ✅ Arquivo
manifest-tools.jsonexiste na raiz do servidor? - ✅ Arquivo está acessível? Teste:
https://tools.artesdosul.com/manifest-tools.json - ✅ Content-Type correto? Deve ser
application/manifest+json
Solução Alternativa (se preferir usar manifest.json):
# No servidor, renomear:
mv manifest-tools.json manifest.json
# E atualizar index.html linha 11:
# De: <link rel="manifest" href="/manifest-tools.json">
# Para: <link rel="manifest" href="/manifest.json">
Problema: Service Worker não registra
Verificações:
- ✅ Arquivo
sw-tools.jsexiste na raiz? - ✅ Arquivo está acessível? Teste:
https://tools.artesdosul.com/sw-tools.js - ✅ Está usando HTTPS? (obrigatório em produção)
- ✅ Console do navegador mostra erros?
Como verificar no Chrome DevTools:
- Abrir DevTools (F12)
- Ir em Application > Service Workers
- Verificar se aparece registrado
- Verificar console para erros
Problema: Ícones não aparecem
Verificações:
- ✅ Pasta
icons/existe na raiz? - ✅ Todos os arquivos PNG existem?
- ✅ Testar acesso:
https://tools.artesdosul.com/icons/icon-192x192.png - ✅ Permissões de arquivo no servidor estão corretas?
Ícones obrigatórios:
icon-192x192.png(mínimo)icon-512x512.png(recomendado)
Problema: Botão de instalação não aparece
Possíveis causas:
- ❌ Manifest inválido (JSON com erros)
- ❌ Falta ícone 192x192 ou 512x512
- ❌ Não está em HTTPS
- ❌ Service Worker não registrado
- ✅ Já está instalado (verificar em modo standalone)
Como verificar:
// No console do navegador:
window.matchMedia('(display-mode: standalone)').matches
// Se retornar true, já está instalado
🔍 Ferramenta de Diagnóstico
Use diagnostico-pwa.html para verificar automaticamente:
- Acesse:
https://tools.artesdosul.com/diagnostico-pwa.html - A ferramenta verificará:
- ✅ HTTPS ativo
- ✅ Service Worker API disponível
- ✅ Manifest carregando
- ✅ Service Worker registrado
- ✅ Ícones acessíveis
- ✅ Pronto para instalar
📋 Checklist de Deploy
Arquivos que DEVEM estar no servidor:
/
├── index.html ✅
├── manifest-tools.json ✅ (ou manifest.json)
├── sw-tools.js ✅
├── icons/
│ ├── icon-16x16.png ✅
│ ├── icon-32x32.png ✅
│ ├── icon-72x72.png ✅
│ ├── icon-96x96.png ✅
│ ├── icon-128x128.png ✅
│ ├── icon-144x144.png ✅
│ ├── icon-152x152.png ✅
│ ├── icon-192x192.png ✅ OBRIGATÓRIO
│ ├── icon-384x384.png ✅
│ └── icon-512x512.png ✅ OBRIGATÓRIO
Verificações Pós-Deploy:
- Manifest acessível:
curl -I https://tools.artesdosul.com/manifest-tools.json # Deve retornar: HTTP/1.1 200 OK # Content-Type: application/manifest+json - Service Worker acessível:
curl -I https://tools.artesdosul.com/sw-tools.js # Deve retornar: HTTP/1.1 200 OK # Content-Type: application/javascript - Ícones acessíveis:
curl -I https://tools.artesdosul.com/icons/icon-192x192.png curl -I https://tools.artesdosul.com/icons/icon-512x512.png
🛠️ Comandos de Verificação no Navegador
Chrome DevTools:
- Application > Manifest:
- Verificar se manifest está carregado
- Verificar erros
- Verificar ícones encontrados
- Application > Service Workers:
- Verificar se está registrado
- Verificar se está ativo (activated)
- Verificar erros no console
- Console:
- Procurar por
[SW]para mensagens do Service Worker - Verificar erros 404
- Procurar por
Lighthouse Audit:
- Abrir DevTools (F12)
- Ir em Lighthouse
- Selecionar Progressive Web App
- Clicar em Generate report
- Verificar score e problemas
🎯 Solução Rápida
Se o PWA ainda não estiver funcionando após o deploy:
- Limpar cache do navegador:
- DevTools > Application > Clear Storage > Clear site data
- Desregistrar Service Workers antigos:
- DevTools > Application > Service Workers > Unregister
- Recarregar a página:
- Ctrl+Shift+R (hard refresh)
- Verificar console:
- Procurar por erros relacionados a manifest ou service worker
- Usar ferramenta de diagnóstico:
- Acessar
diagnostico-pwa.html
- Acessar
📝 Notas Importantes
- HTTPS é obrigatório em produção
- Service Worker só funciona via HTTP/HTTPS
- Ícones 192x192 e 512x512 são obrigatórios
- Manifest deve ser JSON válido
- Scope deve ser
/para funcionar em todo o site