Flutter’s cross-platform nature allows you to implement push notifications once and deploy to both platforms, but platform-specific configuration is still required.
Prerequisites
Firebase Project
Active Firebase project with FCM enabled
Platform Setup
Android google-services.json and iOS GoogleService-Info.plist
social.plus SDK
social.plus Flutter SDK properly integrated
Certificates
iOS APNs certificate and Android FCM configuration
Step 1: Install Dependencies
Add the Firebase Messaging plugin to yourpubspec.yaml
:
Always use the latest stable versions. Check pub.dev for current version numbers.
Step 2: Platform Configuration
Android Configuration
- Add google-services.json to
android/app/
- Update build.gradle files:
- Add permissions to
android/app/src/main/AndroidManifest.xml
:
iOS Configuration
- Add GoogleService-Info.plist to
ios/Runner/
- Enable Push Notifications capability in Xcode
- Generate APNs certificate following the iOS setup guide
- Update Runner-Info.plist for background modes:
- Update AppDelegate.swift:
Step 3: Upload Certificates to social.plus Console
Android - FCM Service Account
-
Generate FCM service account JSON:
- Go to Firebase Console → Project Settings → Service Accounts
- Click “Generate new private key”
- Download the JSON file
-
Upload to social.plus Console:
- Navigate to Settings → Push Notifications
- Upload the FCM service account JSON file
iOS - APNs Certificate
- Generate .p12 certificate following the iOS setup guide
- Upload to social.plus Console:
- Navigate to Settings → Push Notifications
- Upload the .p12 file with password
Best Practices
Cross-Platform Considerations
Cross-Platform Considerations
Platform-Specific Handling: While Flutter allows shared code, some platform-specific handling is necessary.
State Management
State Management
Token State Management: Keep token state consistent across app lifecycle.
Error Handling
Error Handling
Robust Error Management: Handle various failure scenarios gracefully.
Troubleshooting
Common Issues
Common Issues
Token Not Generated:
- Verify Firebase configuration files are correctly placed
- Check internet connectivity
- Ensure permissions are granted
- Verify APNs certificate is uploaded to social.plus Console
- Test with TestFlight or App Store build (not debug)
- Check iOS project capabilities
- Verify FCM service account JSON is uploaded
- Check google-services.json placement
- Ensure minSdkVersion >= 21
Platform-Specific Issues
Platform-Specific Issues
iOS Debug Builds:
- Push notifications don’t work with debug builds
- Use TestFlight for testing
- Runtime notification permission required
- Handle permission request properly
Related Resources
Firebase Flutter Setup
Official Firebase Messaging for Flutter documentation
Flutter Local Notifications
Plugin for displaying local notifications
iOS APNs Guide
Detailed iOS certificate setup
Android FCM Guide
Android Firebase configuration
Testing Strategy: Always test push notifications on physical devices with production builds, as simulators and debug builds have limitations with push notification delivery.