💡 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:- Add push service credentials to Zixflow dashboard - Configure your APNs certificates or FCM server key in the Zixflow dashboard first
- Enable Push Notifications capability in Xcode (see setup steps below)
- Install the appropriate push module:
ZixflowMessagingPushAPNfor Apple Push NotificationsZixflowMessagingPushFCMfor Firebase Cloud Messaging
Apple Push Notifications (APNs)
Recommended for most iOS apps. Provides native iOS push notification support.Step 1: Enable Push Notifications in Xcode
- Select your project in Xcode
- Go to Target → Signing & Capabilities
- Click + Capability → Add Push Notifications
- Click + Capability → Add Background Modes
- Enable Remote notifications under Background Modes
Step 2: Initialize Zixflow Core SDK
Initialize the core Data Pipelines SDK first in yourAppDelegate:
Step 3: Initialize MessagingPushAPN
Add push notification support after initializing the core SDK:Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
autoFetchDeviceToken | Bool | true | Automatically retrieve and register device token |
autoTrackPushEvents | Bool | true | Track delivered and opened metrics automatically |
showPushAppInForeground | Bool | true | Display push notifications while app is in foreground |
appGroupId | String? | nil | Custom App Group ID for delivery tracking (see Rich Push section) |
Step 4: Use ZixflowAppDelegateWrapper (Recommended)
For automatic push notification handling, useZixflowAppDelegateWrapper:
ZixflowAppDelegateWrapper:
- Automatically registers device tokens with Zixflow
- Handles push notification clicks
- Tracks push metrics (
delivered,opened) - No additional code required for basic push handling
Step 5: Identify Users
Critical: Device tokens must be associated with a user before push notifications can be delivered.- Device tokens link to user profiles when you call
identify() - This ensures notifications are delivered to the correct user
- Always call
identify()after user authentication
Step 6: Rich Push with Notification Service Extension
Add support for rich media (images, videos, GIFs) and reliable delivery tracking.1. Create Notification Service Extension
- In Xcode: File → New → Target
- Select Notification Service Extension
- Name it (e.g., “NotificationServiceExtension”)
- Click Finish (activate scheme when prompted)
2. Add SDK to Extension Target
Swift Package Manager:- Select your project
- Go to the Notification Service Extension target
- General → Frameworks and Libraries
- Click + → Add
ZixflowMessagingPushAPN
Podfile:
3. Configure Notification Service Extension
ReplaceNotificationService.swift content:
4. Setup App Groups (Recommended)
App Groups enable delivery tracking data sharing between your main app and notification extension. Create App Group:- Select your main app target → Signing & Capabilities
- Click + Capability → App Groups
- Click + to add a new group with format:
group.{bundleId}.zixflow- Example:
group.com.yourcompany.app.zixflow
- Example:
- Repeat for your Notification Service Extension target
appGroupId, the SDK will automatically infer it from your bundle ID using the pattern group.{bundleId}.zixflow. Only set this if using a custom App Group name.
Firebase Cloud Messaging (FCM)
Use FCM if you need cross-platform push support or already use Firebase services.Step 1: Setup Firebase Project
- Go to https://console.firebase.google.com
- Create a new project or select existing project
- Add your iOS app to the Firebase project
- Download
GoogleService-Info.plist - Add
GoogleService-Info.plistto your Xcode project root
Step 2: Install Firebase SDK
CocoaPods (recommended for FCM):Step 3: Enable Push Capabilities
Follow the same Xcode capabilities setup as APNs (Step 1 of APNs section).Step 4: Initialize Firebase and Zixflow
Step 5: Identify Users
Same as APNs - identify users to associate device tokens:Step 6: Rich Push with FCM
Follow the same Notification Service Extension setup as APNs, but import FCM module:Advanced Push Notification Features
Deep Links and Universal Links
Every Zixflow push notification may carry adeeplink_url at the top level and per-button deeplinks in action_buttons.
Priority order for navigation:
- If an action button was tapped → use
action_buttons[index].deeplink - If body was tapped → use
deeplink_url - If neither is set → open app to default screen
Push Notification Tracking
Zixflow automatically tracks push notification lifecycle events when usingZixflowAppDelegateWrapper. If you need custom tracking or are not using the wrapper, implement tracking manually.
Understanding Push Tracking Events
Zixflow tracks three key push notification events:- Delivered - When the notification arrives on the device
- Opened - When the user taps the notification
- Action Clicked - When the user taps an action button
The Push Payload
Zixflow injects special fields into every push notification’suserInfo:
| Field | Purpose |
|---|---|
Zixflow-Delivery-ID | Unique ID linking to the campaign delivery |
Zixflow-Delivery-Token | The APNs token the notification was sent to |
Manual Tracking Implementation
If not usingZixflowAppDelegateWrapper, implement UNUserNotificationCenterDelegate:
1. Track Delivery (Foreground)
ZixflowAppDelegateWrapper, the SDK handles all tracking automatically. Only implement manual tracking if you need custom behavior or are not using the wrapper.
Decision Flowchart
Use this when deciding which SDK call to make for any notification interaction:- Always track
.deliveredwhen the notification arrives - Always track
.openedbefore tracking action clicks - Action button taps fire both
.openedand the action clicked event - Use the
Zixflow-Delivery-IDandZixflow-Delivery-Tokenfrom the payload for all tracking calls
Manual Device Token Registration
If you disableautoFetchDeviceToken, register manually:
Action Buttons
Action buttons allow users to interact with notifications without opening the app. Theaction_buttons field in the push payload is a JSON-encoded string.
Payload format:
- Maximum 2 buttons per notification (iOS system limit)
- Button index is 0-based (leftmost = index 0)
deeplinkmay be empty — handle gracefully- Button labels in pre-registration can be generic (“Action 1”, “Action 2”)
- The actual button names from the payload are tracked in analytics via
action_name
Remove Device Token
When user logs out or disables notifications: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
Important: Push notifications require a physical iOS device. The iOS Simulator cannot receive push notifications.4. Send Test Push from Zixflow
- Log into Zixflow dashboard
- Navigate to Messaging → Push Notifications
- Create a test push notification
- Send to a specific user (using
userIdfromidentify())
Best Practices
- Always identify users before sending push notifications
- Use Notification Service Extension for rich push and reliable delivery tracking
- Configure App Groups for delivery metric persistence
- Handle permission requests gracefully - explain value to users
- Test thoroughly on physical devices across iOS versions
- Enable debug logging during development
- Handle deep links to provide seamless user experience
- Monitor metrics in Zixflow dashboard to track engagement