Plano de Implementação — Push Notifications Marketing
Visão Geral
Sistema de push notifications de marketing para os apps Prestador e Cliente, usando Firebase Cloud Messaging (FCM) via kreait/laravel-firebase. Scheduler dispara 3x/dia (08h, 13h, 19h), cada notificação tem sua própria condição de elegibilidade e cooldown controlado por log no banco.
1. Condições de Elegibilidade
PROVIDER
| Label |
Condição |
Intervalo |
provider_reforco_educativo_1 |
approval_status = accepted + nunca recebeu nenhum reforço educativo OU o último foi o #2 há ≥3 semanas |
Alterna com #2 a cada 3 semanas |
provider_reforco_educativo_2 |
approval_status = accepted + último reforço recebido foi o #1 há ≥3 semanas |
Alterna com #1 a cada 3 semanas |
provider_motivacional_1 |
approval_status = accepted + não recebeu esta msg há ≥7 dias |
Semanal |
CLIENT
| Label |
Condição |
Cooldown categoria |
Cooldown msg |
cliente_marketing_1..4 |
registration_complete = true |
7 dias |
28 dias |
cliente_recorrencia_1..3 |
≥1 agendamento status = finished + sem agendamento finished nos últimos 30 dias |
7 dias |
28 dias |
cliente_educativo_1..4 |
registration_complete = true (todos) |
7 dias |
28 dias |
cliente_educ_conversao_1..2 |
Nunca agendou com schedule_type = custom OU último foi há >30 dias |
14 dias |
28 dias |
cliente_social_proof_1..2 |
Nunca teve agendamento status = finished OU último foi há >30 dias |
14 dias |
28 dias |
cliente_motivacional_1..3 |
registration_complete = true (todos) |
7 dias |
28 dias |
cliente_contextual_sexta |
registration_complete = true + hoje é sexta-feira |
7 dias |
— |
cliente_contextual_segunda |
registration_complete = true + hoje é segunda-feira |
7 dias |
— |
cliente_contextual_visita |
registration_complete = true (broadcast geral) |
7 dias |
28 dias |
2. Conteúdo das Notificações
PROVIDER — Reforço Educativo
| Label |
Título |
Corpo |
provider_reforco_educativo_1 |
Como funcionam os pedidos Sob Medida |
Eles são enviados para várias diaristas ao mesmo tempo. Aceite rápido para garantir. |
provider_reforco_educativo_2 |
Dica importante |
Pedidos Sob Medida são compartilhados. A confirmação acontece por ordem de aceite. |
PROVIDER — Motivacional
| Label |
Título |
Corpo |
provider_motivacional_1 |
Fique de olho 👀 |
Novos pedidos Sob Medida surgem o tempo todo no app. |
CLIENT — Marketing
| Label |
Título |
Corpo |
cliente_marketing_1 |
Casa limpa sem esforço |
Encontre uma diarista disponível em poucos minutos. |
cliente_marketing_2 |
Precisando de ajuda hoje? |
Veja diaristas disponíveis perto de você. |
cliente_marketing_3 |
Menos preocupação, mais tempo |
Agende sua próxima diária agora mesmo. |
cliente_marketing_4 |
Agenda cheia? |
Uma diarista pode resolver isso hoje. |
CLIENT — Recorrência
| Label |
Título |
Corpo |
cliente_recorrencia_1 |
Hora da próxima diária? |
Faz um tempo desde sua última limpeza 😊 |
cliente_recorrencia_2 |
Rotina em dia |
Que tal agendar sua próxima diária? |
cliente_recorrencia_3 |
Casa limpa dura pouco |
Garanta sua próxima diária no app. |
CLIENT — Educativo
| Label |
Título |
Corpo |
cliente_educativo_1 |
Você sabia? |
No Diária, o pagamento só é liberado após o serviço concluído. |
cliente_educativo_2 |
Mais segurança |
Você acompanha todo o serviço direto pelo app. |
cliente_educativo_3 |
Dica importante |
Avaliações ajudam a manter a qualidade das diaristas. |
cliente_educativo_4 |
Transparência |
Você vê perfil, avaliações e valores antes de contratar. |
CLIENT — Educativo + Conversão
| Label |
Título |
Corpo |
cliente_educ_conversao_1 |
Sob Medida funciona assim |
Seu pedido é enviado para várias diaristas disponíveis. |
cliente_educ_conversao_2 |
Quer mais chances de aceite? |
Pedidos Sob Medida aumentam a rapidez na confirmação. |
CLIENT — Social Proof
| Label |
Título |
Corpo |
cliente_social_proof_1 |
Clientes como você |
Já estão usando o Diária para facilitar a rotina. |
cliente_social_proof_2 |
Diaristas bem avaliadas |
Veja profissionais recomendadas perto de você. |
CLIENT — Motivacional
| Label |
Título |
Corpo |
cliente_motivacional_1 |
Sua casa merece cuidado |
E você merece tempo livre. |
cliente_motivacional_2 |
Chegue em casa e relaxe |
A limpeza fica por nossa conta. |
cliente_motivacional_3 |
Menos bagunça, mais bem-estar |
Agende sua diária quando quiser. |
CLIENT — Contextual
| Label |
Título |
Corpo |
cliente_contextual_sexta |
Sexta chegando |
Que tal deixar a casa pronta pro fim de semana? |
cliente_contextual_segunda |
Segunda organizada |
Comece a semana com a casa limpa. |
cliente_contextual_visita |
Visita marcada? |
Uma diarista pode ajudar hoje. |
3. Estrutura de Arquivos — Backend
app/
├── Enums/
│ ├── PushNotificationTargetEnum.php
│ └── PushNotificationCategoryEnum.php
│
├── Models/
│ ├── DeviceToken.php
│ └── PushNotificationLog.php
│
├── Services/
│ ├── PushNotificationService.php # envia via FCM (kreait)
│ └── PushNotificationDispatcher.php # orquestra o ciclo completo de envio
│
├── Notifications/
│ └── Push/
│ ├── BasePushNotification.php # abstract com LABEL, CATEGORY, TARGET, title(), body(), eligibleUsers()
│ │
│ ├── Prestador/
│ │ ├── ReforcoEducativo/
│ │ │ ├── ReforcoEducativo1Push.php
│ │ │ └── ReforcoEducativo2Push.php
│ │ └── Motivacional/
│ │ └── Motivacional1Push.php
│ │
│ └── Cliente/
│ ├── Marketing/
│ │ ├── Marketing1Push.php
│ │ ├── Marketing2Push.php
│ │ ├── Marketing3Push.php
│ │ └── Marketing4Push.php
│ ├── Recorrencia/
│ │ ├── Recorrencia1Push.php
│ │ ├── Recorrencia2Push.php
│ │ └── Recorrencia3Push.php
│ ├── Educativo/
│ │ ├── Educativo1Push.php
│ │ ├── Educativo2Push.php
│ │ ├── Educativo3Push.php
│ │ └── Educativo4Push.php
│ ├── EducativoConversao/
│ │ ├── EducativoConversao1Push.php
│ │ └── EducativoConversao2Push.php
│ ├── SocialProof/
│ │ ├── SocialProof1Push.php
│ │ └── SocialProof2Push.php
│ ├── Motivacional/
│ │ ├── Motivacional1Push.php
│ │ ├── Motivacional2Push.php
│ │ └── Motivacional3Push.php
│ └── Contextual/
│ ├── ContextualSextaPush.php
│ ├── ContextualSegundaPush.php
│ └── ContextualVisitaPush.php
│
├── Tasks/
│ └── SendPushNotificationsTask.php
│
└── Http/Controllers/Api/
└── DeviceTokenController.php
4. Banco de Dados
device_tokens
id bigint unsigned PK
user_id FK → users.id
token string (FCM device token)
platform enum: android | ios
app_type enum: prestador | cliente
active boolean default true
created_at / updated_at
push_notification_logs
id bigint unsigned PK
label string (ex: 'cliente_marketing_1')
user_id FK → users.id
target string (prestador | cliente)
category string (marketing | recorrencia | educativo | ...)
sent_at timestamp
created_at / updated_at
5. Rotas de API
POST /api/device-tokens → registra token (login / abertura do app)
DELETE /api/device-tokens/{token} → remove token (logout)
6. Scheduler
Em bootstrap/app.php:
$schedule->call(new SendPushNotificationsTask)->dailyAt('08:00');
$schedule->call(new SendPushNotificationsTask)->dailyAt('13:00');
$schedule->call(new SendPushNotificationsTask)->dailyAt('19:00');
7. Frontend — Ambos os Apps
Instalações necessárias (prestador e cliente)
@capacitor/push-notifications
Arquivos a criar em cada app
src/boot/push-notifications.ts → solicita permissão, captura token, registra via API
src/services/pushNotificationService.ts → abstrai chamadas à API de tokens
Firebase
- Criar projeto Firebase (ou dois projetos separados)
- Registrar app Android e iOS de cada um
- Baixar
google-services.json (Android) e GoogleService-Info.plist (iOS) para cada app
- Configurar
capacitor.config.ts de cada app
8. Ordem de Implementação
- Instalar
kreait/laravel-firebase no backend
- Criar migrations (
device_tokens e push_notification_logs)
- Criar Enums (
PushNotificationTargetEnum, PushNotificationCategoryEnum)
- Criar Models (
DeviceToken, PushNotificationLog)
- Criar
DeviceTokenController + rotas
- Criar
PushNotificationService (integração FCM)
- Criar
BasePushNotification (classe abstrata)
- Criar todas as 24 classes de push notifications
- Criar
PushNotificationDispatcher (lógica de cooldown + orquestração)
- Criar
SendPushNotificationsTask + registrar no scheduler
- Frontend Prestador: instalar lib + boot + service
- Frontend Cliente: instalar lib + boot + service