💡 Track your campaigns: The SDK automatically tracks delivery, opens, and clicks. For advanced tracking customization, see Push Notification Tracking.
Prerequisites
Before implementing push notifications:- Configure FCM in Zixflow dashboard - Add your FCM Server Key in the Zixflow dashboard first
- Firebase Project Setup - Create Firebase project and add your Android app
- Install the push messaging module - Add
messagingpushdependency
Step 1: Firebase Project Setup
1. Create Firebase Project
- Go to https://console.firebase.google.com
- Click Add project or select existing project
- Follow the setup wizard
2. Add Android App to Firebase
- In Firebase console, click Add app → Select Android
- Enter your app’s package name (e.g.,
com.yourcompany.app) - (Optional) Add SHA-1 certificate for debugging
- Download
google-services.json
3. Add google-services.json to Project
- Place
google-services.jsonin yourapp/directory - Verify the file is at:
app/google-services.json
Step 2: Add Dependencies
1. Add Google Services Plugin
Project-levelbuild.gradle or build.gradle.kts:
2. Apply Plugin in App Module
App-levelbuild.gradle or build.gradle.kts:
3. Add Zixflow and Firebase Dependencies
Kotlin DSL:Step 3: Initialize Zixflow with Push Support
Basic Initialization (Kotlin)
Basic Initialization (Java)
- Registers a
FirebaseMessagingServicein your manifest - Fetches and registers FCM device tokens
- Handles push notification display and tracking
Step 4: Register Application in AndroidManifest.xml
Ensure your customApplication class is registered:
Step 5: Request Push Notification Permission (Android 13+)
Android 13 (API 33) and higher requires runtime permission for notifications.Request Permission in Activity
Step 6: Identify Users
Critical: Device tokens must be associated with a user before push notifications can be delivered.- When users start the app, they automatically generate a device token
- This token links to their Zixflow profile when you call
identify() - This ensures notifications are delivered to the correct user
Configuration Options
Configure push notification behavior withMessagingPushModuleConfig:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
autoTrackPushEvents | Boolean | true | Automatically track delivered and opened metrics |
pushClickBehavior | PushClickBehavior | ACTIVITY_PREVENT_RESTART | Define behavior when notification is clicked |
notificationCallback | ZixflowPushNotificationCallback | null | Override default push behavior |
Push Click Behaviors
Three strategies control app navigation when notifications are tapped:ACTIVITY_PREVENT_RESTART (Default - Recommended)
- Reuses existing activities when possible
- Ideal for apps with sensitive screens (checkout, payment)
- Prevents interrupting user workflows
ACTIVITY_NO_FLAGS
- Creates new activity instance on every notification tap
- Standard Android behavior
RESET_TASK_STACK
- Clears entire app state
- Prevents back navigation to previous screens
- Use when you want fresh app start
Advanced Features
Customize Notification Appearance
Override notification appearance usingZixflowPushNotificationCallback:
Configure Default Icon and Color
Add metadata toAndroidManifest.xml:
Rich Push Notifications
Rich push (images, videos, GIFs) is automatically supported by the SDK. No additional configuration needed. Send rich media from Zixflow dashboard:- Create push notification campaign
- Add image URL or video URL
- SDK automatically downloads and displays media
Handle Existing FirebaseMessagingService
If your app already implementsFirebaseMessagingService, delegate to Zixflow SDK:
AndroidManifest.xml:
Tracking Push Metrics
The SDK automatically tracks push notification delivery, opens, and action clicks to provide campaign analytics in your Zixflow dashboard. Automatic tracking includes:- Delivered - When notification arrives on device
- Opened - When user taps notification
- Action Clicked - When user taps an action button
For advanced tracking customization, including handling custom FirebaseMessagingService implementations, action button clicks, and non-Zixflow push notifications, see the Push Notification Tracking section below.
Manual tracking (for custom implementations):
Deep Links and Custom Actions
Handle deep links from push notifications:1. Add Intent Filter to Activity
2. Handle Deep Link in Activity
Testing Push Notifications
1. Verify Device Token Registration
Check if device token is registered:2. Enable Debug Logging
Use debug logging to troubleshoot:3. Test on Physical Device or Emulator
Physical Device: Always works with validgoogle-services.json
Emulator: Requires:
- Google Play Services installed
- Signed in with Google account
- Internet connectivity
4. Send Test Push from Zixflow
- Log into Zixflow dashboard
- Navigate to Messaging → Push Notifications
- Create test push notification
- Send to specific user (using
userIdfromidentify())
Troubleshooting
google-services.json Not Found
Error:File google-services.json is missing
Solution:
- Verify
google-services.jsonis inapp/directory - Sync Gradle: File → Sync Project with Gradle Files
- Clean and rebuild: Build → Clean Project → Rebuild Project
Push Notifications Not Received
Symptoms: Notifications sent but not delivered Solutions:- Verify FCM Server Key configured in Zixflow dashboard
- Ensure user is identified:
Zixflow.instance().identify(userId = ...) - Check POST_NOTIFICATIONS permission granted (Android 13+)
- Verify device token registered:
Zixflow.instance().registeredDeviceToken - Test on physical device or emulator with Google Play Services
- Check Firebase console for delivery status
Device Token Not Registering
Symptoms:registeredDeviceToken returns null
Solutions:
- Verify
google-services.jsonis correct and inapp/directory - Ensure
google-servicesplugin is applied - Check Google Play Services available on device
- Verify app package name matches Firebase configuration
- Check logs for FCM token generation errors
Notification Not Displayed
Symptoms: Push delivered but not shown Solutions:- Check notification channels (Android 8.0+)
- Verify notification permission granted
- Ensure app not in “Do Not Disturb” mode
- Check notification settings for your app
- Verify custom notification callback isn’t blocking display
Rich Media Not Loading
Symptoms: Images/videos not appearing in notifications Solutions:- Verify media URL is accessible from device
- Check internet connectivity
- Ensure media format is supported (JPEG, PNG, GIF for images)
- Check file size (large files may timeout)
Best Practices
- Always identify users before sending push notifications
- Request permission thoughtfully - explain value before requesting
- Use ACTIVITY_PREVENT_RESTART for better user experience
- Test on multiple devices and Android versions
- Enable debug logging during development
- Monitor metrics in Zixflow dashboard
- Handle permission denial gracefully
- Test deep links thoroughly
- Customize notification appearance to match app branding
- Keep google-services.json secure - don’t commit to version control