- Created .gitignore to exclude sensitive files and directories. - Added API documentation in API_DOCUMENTATION.md. - Included deployment instructions in DEPLOYMENT.md. - Established project structure documentation in PROJECT_STRUCTURE.md. - Updated README.md with project status and team information. - Added recommendations and status tracking documents. - Introduced testing guidelines in TESTING.md. - Set up CI workflow in .github/workflows/ci.yml. - Created Dockerfile for backend and frontend setups. - Added various service and utility files for backend functionality. - Implemented frontend components and pages for user interface. - Included mobile app structure and services. - Established scripts for deployment across multiple chains.
10 KiB
Push Notification Service Alternatives to Firebase
This document outlines alternatives to Firebase Cloud Messaging (FCM) for push notifications in the ASLE platform.
Current Implementation
The project currently uses:
- Backend:
firebase-adminfor sending notifications via FCM - Mobile:
react-native-push-notificationfor receiving notifications
Alternative Services
1. OneSignal ⭐ Recommended
Pros:
- ✅ Free tier: 10,000 subscribers, unlimited notifications
- ✅ Easy integration with React Native
- ✅ Web dashboard for analytics and targeting
- ✅ Supports iOS, Android, Web, and email
- ✅ Rich notification features (images, buttons, actions)
- ✅ Segmentation and targeting
- ✅ A/B testing
- ✅ Good documentation
Cons:
- ⚠️ Requires OneSignal SDK in mobile app
- ⚠️ Data stored on OneSignal servers
Implementation:
# Backend
npm install onesignal-node
# Mobile
npm install react-native-onesignal
Cost: Free up to 10K subscribers, then $9/month for 10K-100K
2. Pusher Beams (formerly Pusher)
Pros:
- ✅ Simple REST API
- ✅ Good for real-time features
- ✅ WebSocket support
- ✅ Free tier: 2,000 devices
- ✅ Good for multi-platform apps
Cons:
- ⚠️ Smaller community than Firebase/OneSignal
- ⚠️ Less feature-rich than competitors
Implementation:
# Backend
npm install @pusher/push-notifications-server
# Mobile
npm install @pusher/push-notifications-react-native
Cost: Free for 2K devices, then $49/month for 10K devices
3. Amazon SNS (Simple Notification Service)
Pros:
- ✅ Highly scalable (AWS infrastructure)
- ✅ Pay-per-use pricing
- ✅ Supports SMS, email, push, and more
- ✅ Direct integration with AWS services
- ✅ No subscriber limits
- ✅ Enterprise-grade reliability
Cons:
- ⚠️ More complex setup
- ⚠️ Requires AWS account and configuration
- ⚠️ Less user-friendly than Firebase/OneSignal
- ⚠️ No built-in analytics dashboard
Implementation:
# Backend
npm install @aws-sdk/client-sns
Cost: $0.50 per million requests, very cost-effective at scale
4. Airship (formerly Urban Airship)
Pros:
- ✅ Enterprise-focused
- ✅ Advanced segmentation
- ✅ Rich analytics
- ✅ A/B testing
- ✅ Multi-channel (push, SMS, email, in-app)
Cons:
- ⚠️ Expensive for small apps
- ⚠️ Complex setup
- ⚠️ Overkill for simple use cases
Cost: Custom pricing (typically $500+/month)
5. Native Platform APIs (APNs + FCM Direct)
Pros:
- ✅ No third-party dependency
- ✅ Full control
- ✅ No per-notification costs
- ✅ Direct integration
- ✅ Privacy-friendly (no data sent to third parties)
Cons:
- ⚠️ More complex implementation
- ⚠️ Need to manage both iOS (APNs) and Android (FCM) separately
- ⚠️ No built-in analytics
- ⚠️ Need to handle token management yourself
Implementation:
# Backend - For APNs (iOS)
npm install apn
# Backend - For FCM (Android) - can use firebase-admin or native HTTP
# Already have firebase-admin, but can use direct HTTP API
Cost: Free (only infrastructure costs)
6. Expo Push Notifications
Pros:
- ✅ Perfect if using Expo
- ✅ Simple setup
- ✅ Free tier
- ✅ No server needed for basic use
Cons:
- ⚠️ Only works with Expo
- ⚠️ Limited features
- ⚠️ Not suitable for production at scale
Cost: Free
7. Pusher Channels (Real-time + Push)
Pros:
- ✅ Good for apps needing both real-time and push
- ✅ WebSocket + Push in one service
- ✅ Simple API
Cons:
- ⚠️ More expensive than dedicated push services
- ⚠️ Less specialized for push notifications
Cost: $49/month for 200 concurrent connections
8. SendGrid (Twilio)
Pros:
- ✅ Part of Twilio ecosystem
- ✅ Good email + push integration
- ✅ Reliable infrastructure
Cons:
- ⚠️ More focused on email
- ⚠️ Push notifications are secondary feature
Cost: Custom pricing
Comparison Matrix
| Service | Free Tier | Ease of Use | Analytics | Cost at Scale | Best For |
|---|---|---|---|---|---|
| OneSignal | 10K subs | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | $9/month | Most apps |
| Pusher Beams | 2K devices | ⭐⭐⭐⭐ | ⭐⭐⭐ | $49/month | Real-time apps |
| AWS SNS | Pay-per-use | ⭐⭐⭐ | ⭐⭐ | Very low | Enterprise/Scale |
| Airship | None | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | $500+/month | Enterprise |
| Native APIs | Free | ⭐⭐ | ⭐ | Infrastructure only | Privacy-focused |
| Expo Push | Free | ⭐⭐⭐⭐⭐ | ⭐⭐ | Free | Expo apps |
Recommended Migration Path
Option 1: OneSignal (Easiest Migration)
Why: Best balance of features, ease of use, and cost.
Steps:
- Install OneSignal SDK in mobile app
- Replace
PushNotificationServicewith OneSignal service - Update backend to use OneSignal REST API
- Migrate device tokens
Code Example:
// backend/src/services/onesignal.ts
import axios from 'axios';
export class OneSignalService {
private appId: string;
private apiKey: string;
constructor() {
this.appId = process.env.ONESIGNAL_APP_ID!;
this.apiKey = process.env.ONESIGNAL_API_KEY!;
}
async sendNotification(notification: PushNotification): Promise<void> {
await axios.post(
'https://onesignal.com/api/v1/notifications',
{
app_id: this.appId,
include_player_ids: [notification.token],
headings: { en: notification.title },
contents: { en: notification.body },
data: notification.data,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${this.apiKey}`,
},
}
);
}
}
Option 2: AWS SNS (Most Scalable)
Why: Best for high-scale applications, pay-per-use pricing.
Steps:
- Set up AWS SNS topics
- Create platform applications for iOS/Android
- Replace service with AWS SNS client
- Handle APNs and FCM through SNS
Code Example:
// backend/src/services/sns.ts
import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';
export class SNSService {
private sns: SNSClient;
private iosPlatformArn: string;
private androidPlatformArn: string;
constructor() {
this.sns = new SNSClient({ region: process.env.AWS_REGION });
this.iosPlatformArn = process.env.AWS_SNS_IOS_ARN!;
this.androidPlatformArn = process.env.AWS_SNS_ANDROID_ARN!;
}
async sendNotification(notification: PushNotification, platform: 'ios' | 'android'): Promise<void> {
const platformArn = platform === 'ios' ? this.iosPlatformArn : this.androidPlatformArn;
await this.sns.send(new PublishCommand({
TargetArn: platformArn,
Message: JSON.stringify({
default: notification.body,
APNS: JSON.stringify({
aps: {
alert: {
title: notification.title,
body: notification.body,
},
},
...notification.data,
}),
GCM: JSON.stringify({
notification: {
title: notification.title,
body: notification.body,
},
data: notification.data,
}),
}),
MessageStructure: 'json',
}));
}
}
Option 3: Native APIs (Most Control)
Why: No third-party dependency, full control, privacy-friendly.
Steps:
- Keep FCM for Android (or use direct HTTP API)
- Add APNs for iOS
- Create unified service wrapper
- Handle token management
Code Example:
// backend/src/services/native-push.ts
import apn from 'apn';
import axios from 'axios';
export class NativePushService {
private apnProvider: apn.Provider | null = null;
private fcmServerKey: string;
constructor() {
// Initialize APNs for iOS
if (process.env.APNS_KEY_ID && process.env.APNS_TEAM_ID) {
this.apnProvider = new apn.Provider({
token: {
key: process.env.APNS_KEY_PATH!,
keyId: process.env.APNS_KEY_ID!,
teamId: process.env.APNS_TEAM_ID!,
},
production: process.env.NODE_ENV === 'production',
});
}
this.fcmServerKey = process.env.FCM_SERVER_KEY!;
}
async sendToIOS(token: string, notification: PushNotification): Promise<void> {
if (!this.apnProvider) throw new Error('APNs not configured');
const apnNotification = new apn.Notification();
apnNotification.alert = {
title: notification.title,
body: notification.body,
};
apnNotification.topic = process.env.APNS_BUNDLE_ID!;
apnNotification.payload = notification.data;
apnNotification.sound = 'default';
await this.apnProvider.send(apnNotification, token);
}
async sendToAndroid(token: string, notification: PushNotification): Promise<void> {
await axios.post(
'https://fcm.googleapis.com/fcm/send',
{
to: token,
notification: {
title: notification.title,
body: notification.body,
},
data: notification.data,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `key=${this.fcmServerKey}`,
},
}
);
}
}
Migration Checklist
- Choose alternative service
- Set up account/credentials
- Install SDKs/packages
- Create new service class
- Update mobile app to use new SDK
- Migrate device tokens
- Update environment variables
- Test on iOS and Android
- Update documentation
- Remove Firebase dependencies (if switching completely)
- Monitor notification delivery rates
Recommendation
For the ASLE project, I recommend OneSignal because:
- ✅ Easy migration from Firebase
- ✅ Free tier covers most use cases
- ✅ Excellent React Native support
- ✅ Rich analytics and targeting
- ✅ Good documentation and community
- ✅ Cost-effective scaling
If you need maximum control and privacy, use Native APIs (APNs + FCM direct).
If you're already on AWS and need enterprise scale, use AWS SNS.