💡 Track your campaigns: The SDK automatically tracks delivery, opens, and clicks. For advanced tracking customization and implementation details, see Push Notification Tracking.
Prerequisites
Before implementing push notifications:- Configure FCM in Zixflow dashboard - Add FCM Server Key to Zixflow dashboard
- Firebase Project Setup - Create Firebase project and add both iOS and Android apps
- Device tokens must be associated with users - Call
identify()before sending notifications - Test on physical devices only - Emulators/simulators cannot receive push notifications
Platform-Specific Requirements
iOS Requirements
- iOS 13.0 or higher
- Xcode 14.0 or higher
- Push Notifications capability enabled in Xcode
- Notification Service Extension for rich push (images, videos)
- Physical Device required for testing
Android Requirements
- API Level 21 (Android 5.0) or higher
- Firebase Project configured
- google-services.json in
android/app/directory - POST_NOTIFICATIONS permission for Android 13+ (API 33+)
Step 1: Firebase Project Setup
1. Create Firebase Project
- Go to https://console.firebase.google.com
- Click Create a project or select existing project
- Follow the setup wizard
2. Add iOS App to Firebase
- In Firebase console, click Add app → Select iOS
- Enter iOS Bundle ID (e.g.,
com.yourcompany.app) - Download
GoogleService-Info.plist - Add
GoogleService-Info.plisttoios/Runner/directory in Xcode
3. Add Android App to Firebase
- In Firebase console, click Add app → Select Android
- Enter Android package name (same as iOS bundle ID)
- Download
google-services.json - Place
google-services.jsoninandroid/app/directory
Step 2: Add Dependencies
Update yourpubspec.yaml:
Step 3: Configure Flutter Code
Initialize Firebase and Zixflow
Update yourmain.dart:
firebase_options.dart, use FlutterFire CLI:
Step 4: Handle Push Notifications
Complete push notification handling implementation:Step 5: Identify Users
Critical: Device tokens must be associated with a user before push notifications can be delivered.- Device tokens are automatically generated when the app starts
- Tokens are linked to Zixflow profiles when you call
identify() - This ensures notifications are delivered to the correct user
iOS-Specific Setup
Step 1: Enable Push Capabilities in Xcode
- Open
<yourAppName>.xcworkspaceinios/folder - Select your main app target (Runner)
- Go to Signing & Capabilities tab
- Click + Capability → Add Push Notifications
- Click + Capability → Add Background Modes
- Enable Remote notifications under Background Modes
Step 2: Create Notification Service Extension
For rich push notifications (images, videos, GIFs): 1. Create Extension in Xcode:- Select File → New → Target
- Choose Notification Service Extension
- Name it
NotificationServiceExtension - Click Finish
- Click Cancel when asked about activation
ios/Podfile:
- Add
FlutterGeneratedPluginSwiftPackageto NotificationServiceExtension target - Go to General → Frameworks and Libraries
"YOUR_API_KEY" with your actual API key.
Step 3: Configure AppDelegate.swift
Updateios/Runner/AppDelegate.swift:
- Set
showPushAppInForeground(true)to display notifications when app is active - Customize presentation with
userNotificationCenter:willPresent:delegate method - Available options:
.banner,.list,.badge,.sound
- Your app needs permission to play sounds (requested via
requestPermission) - Users can disable sound in iOS Settings
- Use “Default” sound setting for best experience (triggers vibration when sound is disabled)
- Custom sounds require additional native configuration
Android-Specific Setup
Android push is automatically configured when following the Getting Started instructions. Additional customization is available:Step 1: Configure Gradle
Project-levelandroid/build.gradle:
android/app/build.gradle:
Step 2: Add Permissions
Add toandroid/app/src/main/AndroidManifest.xml:
Step 3: Customize Notification Icon and Color
Add toandroid/app/src/main/AndroidManifest.xml inside <application> tag:
- Place white icon PNG in
android/app/src/main/res/drawable/ic_notification.png - Create multiple sizes for different densities (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi)
android/app/src/main/res/values/colors.xml:
Local Notifications (Foreground Display)
Show notifications when app is in foreground usingflutter_local_notifications:
Rich Push Payload Structure
Zixflow automatically handles rich push notifications. Here’s how to structure payloads:iOS FCM Payload
Android Payload
Testing Push Notifications
1. Verify Device Token Registration
Check if device token is registered:2. Enable Debug Logging
Set log level to debug during development:3. Test on Physical Devices
iOS:- Push notifications do not work on iOS Simulator
- Must use physical iOS device
- Ensure APNs certificate configured in Firebase
- Emulator works if Google Play Services installed
- Physical device always recommended
- Ensure FCM Server Key configured in Zixflow dashboard
4. Send Test Push from Zixflow
- Log into Zixflow dashboard
- Navigate to Messaging → Push Notifications
- Create test push notification with image
- Send to specific user (using
userIdfromidentify())
Troubleshooting
Firebase Configuration Issues
Error:GoogleService-Info.plist not found (iOS)
Solution:
- Ensure file is in
ios/Runner/directory - Verify file is added to Xcode target (check target membership)
- Clean and rebuild:
flutter clean && flutter pub get
Error:
google-services.json not found (Android)
Solution:
- Ensure file is in
android/app/directory - Verify Google Services plugin applied in
android/app/build.gradle - Sync Gradle files
Push Notifications Not Received
iOS Checklist:- Push Notifications capability enabled in Xcode
- APNs certificate uploaded to Firebase
- Testing on physical device (not simulator)
- User identified:
Zixflow.instance.identify() - Permission granted by user
- Foreground display configured if app is active
-
google-services.jsoninandroid/app/directory - Google Services plugin applied
- FCM Server Key in Zixflow dashboard
- POST_NOTIFICATIONS permission granted (Android 13+)
- Device registered for push
Rich Push Not Working (Images)
iOS Solutions:- Ensure Notification Service Extension properly configured
- Verify extension has correct dependencies in Podfile
- Check
mutable-content: 1in push payload - Verify image URL is accessible
- Check extension logs for errors
- Verify image URL accessible from device
- Check internet connectivity
- Ensure image format supported (JPEG, PNG, GIF)
Permission Denied
Symptoms: User denied push permission Solutions:- Explain value before requesting permission
- Show in-app message about benefits
- Guide users to Settings to enable manually:
Device Token Not Available
Symptoms:getToken() returns null
Solutions:
- Verify Firebase initialized before calling
getToken() - Check Google Play Services available (Android)
- Ensure internet connectivity
- Review native logs for errors
- Rebuild app and retry
Best Practices
- Initialize Firebase first - Before Zixflow SDK
- Request permission thoughtfully - Explain value before asking
- Identify users immediately - After authentication
- Test on physical devices - Simulators have limitations
- Use rich push - Images increase engagement
- Handle deep links - Provide seamless navigation
- Monitor metrics - Track delivery and open rates
- Enable debug logging - During development only
- Test both platforms - iOS and Android behave differently
- Clear identity on logout - Call
clearIdentify() - Configure App Groups (iOS) - For reliable delivery tracking