Skip to main content
Complete guide to implementing push notifications with Zixflow using Firebase Cloud Messaging (FCM).
Track your campaigns: With the default FCM module, the SDK auto-tracks delivered and body opened. Action-button clicks are never automatic — use a receiver + track(...). For the dual-path custom FCM service used in the Android example, see Push Notification Tracking.

Prerequisites

Before implementing push notifications:
  1. Configure FCM in Zixflow dashboard - Add your FCM Server Key in the Zixflow dashboard first
  2. Firebase Project Setup - Create Firebase project and add your Android app
  3. Install the push messaging module - Add messaging-push-fcm dependency
Important: FCM setup is required before implementing push notifications. This integration serves as the foundation for all push messaging capabilities.

Step 1: Firebase Project Setup

1. Create Firebase Project

  1. Go to https://console.firebase.google.com
  2. Click Add project or select existing project
  3. Follow the setup wizard

2. Add Android App to Firebase

  1. In Firebase console, click Add app → Select Android
  2. Enter your app’s package name (e.g., com.yourcompany.app)
  3. (Optional) Add SHA-1 certificate for debugging
  4. Download google-services.json

3. Add google-services.json to Project

  1. Place google-services.json in your app/ directory
  2. Verify the file is at: app/google-services.json

Step 2: Add Dependencies

1. Add Google Services Plugin

Project-level build.gradle.kts:
Project-level build.gradle (Groovy):

2. Apply Plugin in App Module

App-level build.gradle or build.gradle.kts:

3. Add Zixflow and Firebase Dependencies

Kotlin DSL:
Groovy DSL:

Step 3: Initialize Zixflow with Push Support

Basic Initialization (Kotlin)

Basic Initialization (Java)

Important: The SDK automatically:
  • Registers a FirebaseMessagingService in your manifest
  • Fetches and registers FCM device tokens
  • Handles push notification display and tracking

Step 4: Register Application in AndroidManifest.xml

Ensure your custom Application 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.
Important Notes:
  • 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 with MessagingPushModuleConfig:

Configuration Options

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 using ZixflowPushNotificationCallback:

Attach action buttons

The SDK builds title, body, and image but does not auto-attach action buttons. Parse action_buttons from payload.extras inside onNotificationComposed and call builder.addAction with PendingIntents that your app handles (for example a BroadcastReceiver).
Register a BroadcastReceiver (for example NotificationActionReceiver) with matching intent action. In the receiver: track Opened, then Push Notification Action Clicked, then NotificationManagerCompat.cancel(notificationId) (action presses do not auto-dismiss). See Push Notification Tracking and NotificationActionReceiver.kt.

Configure Default Icon and Color

Add metadata to AndroidManifest.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:
  1. Create push notification campaign
  2. Add image URL or video URL
  3. SDK automatically downloads and displays media

Custom FirebaseMessagingService (dual-path)

Android routes FCM to one FirebaseMessagingService. If you declare your own, remove the SDK service from the merged manifest, then try the SDK helper first and fall back to manual display + metrics when it returns false. Reference: CustomFirebaseMessagingService.kt.
Accept both Zixflow- and ZIXFLOW- delivery key casings. For body opens on the manual path, put delivery ID/token on the content PendingIntent extras and call trackMetric(Opened) in your Activity — see the example MainActivity.handlePushOpenIntent.

Tracking Push Metrics

Full details: Push Notification Tracking.

For Zixflow campaign taps, the Android example does not rely on https intent filters alone. It:
  1. Puts deeplink_url on the content PendingIntent (body) and per-button deeplink on action intents
  2. Tracks Opened / Action Clicked (see Push Notification Tracking)
  3. Opens the URL via DeeplinkRouter — custom scheme hosts → Activities; otherwise ACTION_VIEW
You can still add HTTPS / app-link intent filters for cold starts from the browser:
Full open / action / deeplink contract: Push Notification Tracking.

Testing Push Notifications

1. Verify Device Token Registration

Check if device token is registered:

2. Enable Debug Logging

Use debug logging to troubleshoot:
View logs in Android Studio Logcat (filter by “Zixflow”).

3. Test on Physical Device or Emulator

Physical Device: Always works with valid google-services.json Emulator: Requires:
  • Google Play Services installed
  • Signed in with Google account
  • Internet connectivity

4. Send Test Push from Zixflow

  1. Log into Zixflow dashboard
  2. Navigate to MessagingPush Notifications
  3. Create test push notification
  4. Send to specific user (using userId from identify())

Troubleshooting

google-services.json Not Found

Error: File google-services.json is missing Solution:
  1. Verify google-services.json is in app/ directory
  2. Sync Gradle: FileSync Project with Gradle Files
  3. Clean and rebuild: BuildClean ProjectRebuild Project

Push Notifications Not Received

Symptoms: Notifications sent but not delivered Solutions:
  1. Verify FCM Server Key configured in Zixflow dashboard
  2. Ensure user is identified: Zixflow.instance().identify(userId = ...)
  3. Check POST_NOTIFICATIONS permission granted (Android 13+)
  4. Verify device token registered: Zixflow.instance().registeredDeviceToken
  5. Test on physical device or emulator with Google Play Services
  6. Check Firebase console for delivery status

Device Token Not Registering

Symptoms: registeredDeviceToken returns null Solutions:
  1. Verify google-services.json is correct and in app/ directory
  2. Ensure google-services plugin is applied
  3. Check Google Play Services available on device
  4. Verify app package name matches Firebase configuration
  5. Check logs for FCM token generation errors

Notification Not Displayed

Symptoms: Push delivered but not shown Solutions:
  1. Check notification channels (Android 8.0+)
  2. Verify notification permission granted
  3. Ensure app not in “Do Not Disturb” mode
  4. Check notification settings for your app
  5. Verify custom notification callback isn’t blocking display

Rich Media Not Loading

Symptoms: Images/videos not appearing in notifications Solutions:
  1. Verify media URL is accessible from device
  2. Check internet connectivity
  3. Ensure media format is supported (JPEG, PNG, GIF for images)
  4. Check file size (large files may timeout)

Best Practices

  1. Always identify users before sending push notifications
  2. Request permission thoughtfully - explain value before requesting
  3. Use ACTIVITY_PREVENT_RESTART for better user experience
  4. Test on multiple devices and Android versions
  5. Enable debug logging during development
  6. Monitor metrics in Zixflow dashboard
  7. Handle permission denial gracefully
  8. Test deep links thoroughly
  9. Customize notification appearance to match app branding
  10. Keep google-services.json secure - don’t commit to version control