Workflow: Add Push Notifications
Objective
Add remote push notifications (APNs directly or via FCM) with in-context permission, token upload, foreground handling, and deep-link tap routing.
Inputs
- Push provider choice (APNs vs FCM), payload schema, deep-link targets.
- Backend endpoint to receive device tokens.
Outputs
- Registration + permission flow, token upload, notification handling, deep-link routing, tests.
Step-by-Step Process
- Enable capabilities (DevOps Expert) — Push Notifications capability, APNs auth key (.p8); for FCM, configure the APNs key in Firebase.
- Request permission in context — explain value first, then
UNUserNotificationCenter.requestAuthorization(seeskills/notifications/ios/apns.mdorfcm.md). - Upload the token — device token (APNs) or registration token (FCM); handle refresh.
- Handle presentation —
willPresentfor foreground banners. - Route taps — parse
userInfodeep link through the router; handle cold start. - Security (Security Expert) — ensure no PII/secrets in payloads; don't authorize off payload contents.
- Test registration, foreground, and tap routing (use a stub router); document silent-push limits if used.
Validation Steps
- Permission prompt appears in context; denial handled gracefully.
- Token uploaded and refreshed; pushes arrive on device.
- Foreground banners shown; taps route to the correct screen (incl. cold start).
Failure Scenarios
- Missing APNs key (FCM) → iOS delivery fails silently; verify configuration.
- Stale tokens → handle refresh + server cleanup.
- Permission denied → degrade gracefully; offer Settings deep link.
- Malformed payload → router returns
.unknown; no crash.
AI Agent Instructions
- Request permission in context, never on first launch with no explanation.
- Always upload + refresh tokens; route taps through the centralized deep-link router.
- Keep payloads non-sensitive; handle cold-start launches from notifications.
Acceptance Criteria
- [ ] Capability + APNs key configured.
- [ ] In-context permission; token uploaded/refreshed.
- [ ] Foreground handling + tap routing (incl. cold start).
- [ ] No sensitive data in payloads.
- [ ] Handling covered by tests.