Push notification options #348
AndreaDiazCorreia
started this conversation in
Ideas
Replies: 1 comment
-
|
@grunch this is the research from claude |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Push Notifications for Privacy-Focused Flutter/Nostr Apps: Implementation Guide
The fundamental reality: No single push notification solution works across all three platform scenarios (iOS, Android with Google Services, Android without Google Services). You must implement a multi-backend architecture with intelligent fallback strategies.
Critical Platform Constraints and Best Solution
iOS requires APNs - Apple provides no alternatives for App Store applications. All iOS push notifications must route through Apple Push Notification service, which means Apple will see notification metadata (timing, device identifiers, IP addresses) even if you encrypt content.
Android with Google Play Services: FCM works universally but requires Google infrastructure. Google can see notification content unless you implement end-to-end encryption yourself (FCM provides no built-in E2E encryption).
Android without Google Services (GrapheneOS, LineageOS): FCM fundamentally doesn't work without Google Play Services. The best solution is UnifiedPush, an open-source decentralized protocol with mandatory encryption that's gained significant adoption in privacy-focused apps.
Recommended architecture for your use case:
This approach gives privacy-conscious users maximum control while maintaining functionality for mainstream users.
How Firebase Cloud Messaging Actually Works
Privacy Characteristics
FCM has significant privacy implications that conflict with privacy-focused app goals:
What Google can see by default:
Recent academic research (arXiv 2024, "The Medium is the Message") found FCM enables extensive metadata tracking, and many "secure messaging" apps inadvertently leak sensitive data to FCM in plaintext.
Platform Support Matrix
Making FCM More Private
If you must use FCM, implement these mitigations:
1. End-to-End Encryption (Essential)
2. Empty Wake-Up Messages
3. What Still Leaks Even with perfect E2E encryption implementation:
For a privacy-focused Nostr app with NIP-59, relying solely on FCM contradicts your privacy goals.
UnifiedPush: The Privacy-Preserving Alternative
What It Is
UnifiedPush is an open-source, decentralized push notification protocol that allows users to choose their push provider. It's the only viable solution for truly degoogled Android and has gained significant adoption in privacy-focused apps.
Architecture:
Privacy Advantages Over FCM
1. User Choice: Users select which push provider to trust (or self-host) 2. Mandatory Encryption: RFC8291 encryption required - push servers cannot read content 3. Decentralization: No single surveillance point (unlike Google's monopoly) 4. Data Minimization: Distributors don't need app lists or advertising IDs 5. Compartmentalization: Single-purpose apps with minimal permissions (vs. Play Services' system-level privileges)
Platform Support - Critical Limitation
Android: ✅ Excellent - works perfectly with or without Google Play Services iOS: ❌ Not supported - Apple's restrictions prevent background distributors
iOS doesn't allow persistent background services required for UnifiedPush distributors. This is an architectural impossibility, not a missing feature. There is no workaround without jailbreaking.
Flutter Implementation
Package:
unifiedpush(pub.dev, version 6.0.2)Embedded FCM Distributor (Best of Both Worlds)
For Android apps that want to support both mainstream users AND privacy-focused users:
This provides:
Available Distributors
Production-ready distributors for users:
Users install ONE distributor, and ALL UnifiedPush-enabled apps share that single connection (battery efficient).
Real-World Adoption
35+ apps support UnifiedPush, including:
The protocol is stable, production-ready, and actively maintained with funding from NLnet/European Commission.
Alternative Push Solutions
ntfy.sh - The Most Practical Self-Hosted Option
Key Features:
Privacy:
Flutter Integration:
Battery Impact: 0-1% over 17 hours with instant delivery (tested by ntfy developers)
Limitation: iOS still requires ntfy.sh infrastructure (can't use fully self-hosted due to Apple's APNs requirement)
Gotify - Android-Only Self-Hosted
Key Features:
Critical Limitation: No iOS support - Apple prohibits WebSocket background connections
Use Case: Good for Android-only apps or internal tools, but not viable for cross-platform consumer apps
WebSocket and Polling Alternatives
WebSocket Persistent Connection:
Polling:
Recommendation: Don't rely on polling or WebSockets as primary solution - use UnifiedPush or push services
How Nostr Apps Handle Push Notifications
Damus (iOS) - APNS with Privacy Preservation
Architecture:
Key Implementation Details:
NIP-59 Handling:
Code Pattern (from Damus):
Amethyst (Android) - Multi-Strategy Approach
Primary Strategy: Local notifications with relay subscriptions (WebSocket connections)
Optional Push: Year+ old push notification spec with NIP-98 auth
Configuration:
Pokey Integration: For degoogled Android users
NIP-59 Gift-Wrapped Events and Push Challenge
Three-Layer Architecture:
Push Notification Challenge:
Current Solutions:
Proposed NIP PR #1528: Push Notification Event Watcher API
Status: Open PR, based on Amethyst's year-old implementation
Key Features:
Not yet finalized but demonstrates emerging standardization efforts
Recommended Architecture for Your Flutter/Nostr App
Multi-Backend Strategy (Required for Cross-Platform)
iOS Implementation (APNs Required)
Option 1: FCM for ease (routes through Google → Apple)
Option 2: Direct APNs (more control, more complexity)
Privacy Recommendation: Use data-only messages, encrypt with user's Nostr keys, send only event IDs in notifications
Android with Google Play Services
Use UnifiedPush with Embedded FCM Distributor:
Benefits:
Android without Google Play Services (GrapheneOS/LineageOS)
Require UnifiedPush Distributor:
User Experience Flow:
Detecting Google Play Services
NIP-59 Encryption and Push Notification Privacy
Never Send Decrypted Content
Critical Rule: Push notification payloads must NEVER contain decrypted NIP-59 content
Backend Implementation:
Client-Side Handling:
Privacy Tradeoffs
What Push Servers Can See (even with proper implementation):
What Push Servers CANNOT See (with proper implementation):
Best Privacy: Pokey-style pull notifications (Android only)
Implementation Roadmap
Phase 1: MVP (2-3 weeks)
Week 1: iOS Foundation
Week 2: Android with Google Services
Week 3: Android without Google Services
Phase 2: Privacy Enhancements (1-2 weeks)
NIP-59 Integration:
Self-Hosting Documentation:
Phase 3: Advanced Features (1-2 weeks)
User Controls:
Monitoring:
Technical Implementation Details
Flutter Packages Required
Complete Multi-Backend Service
Backend Server Implementation
Your Nostr relay or backend needs to support multiple push formats:
Self-Hosted vs Managed Trade-offs
For Your Privacy-Focused Nostr App
Self-Hosted (Recommended):
Managed (Pragmatic):
Hybrid Recommendation:
Key Recommendations
Architecture
Implement multi-backend from day one - retrofitting is painful:
Privacy Priorities
User Experience
Be transparent about trade-offs:
Guide degoogled users:
Testing
Test on actual devices:
Test scenarios:
Conclusion: Practical Path Forward
For your privacy-focused Flutter/Nostr app with NIP-59, here's the pragmatic implementation path:
Minimal Viable Push (MVP)
iOS: Use FCM → APNs (only option, be transparent about this) Android: Use
unifiedpushpackage with embedded FCM distributor Backend: Support both FCM tokens and UnifiedPush WebPush endpointsThis gives you:
Privacy-Enhanced (Future)
Add Pokey integration: For Android users who want zero push servers Document self-hosting: Guide for ntfy server setup WoT filtering: Reduce spam without server-side content access Tor support: For users who want IP privacy
What You CANNOT Avoid
What You CAN Control
The UnifiedPush + embedded FCM approach is the sweet spot for your use case - it balances privacy (for those who want it), convenience (for mainstream users), and practical development effort.
Beta Was this translation helpful? Give feedback.
All reactions