Upgrade from 3.x to 4.0.0

Updated

This page details breaking changes from version 3.x to 4.0.0 of the SDK, specifically for users utilizing Firebase Cloud Messaging (FCM) for push notifications.

What changed?

Version 4.0.0 introduces a breaking change for users who utilize Firebase Cloud Messaging (FCM) for push notifications. The change improves the FCM integration by consolidating Firebase dependencies into a dedicated wrapper package.

FCM Integration Changes

  • New dependency required: CioFirebaseWrapper package is now required for FCM push notifications
  • Import statement updated: Add import CioFirebaseWrapper wherever you use import CioMessagingPushFCM
  • Initialize method unchanged: Continue using MessagingPushFCM.initialize() but it now comes from the new package

Note: This change only affects users utilizing FCM for push notifications. If you use Apple Push Notification Service (APNs), no changes are required.

Upgrade process

1. Update dependencies

Update your dependency management configuration to include the new CioFirebaseWrapper package.

Add the CioFirebaseWrapper package to your project in Xcode:

  1. In Xcode, go to File > Add Package Dependencies
  2. Add https://github.com/customerio/customerio-ios-fcm.git if not already added
  3. Select the CioFirebaseWrapper package in addition to your existing packages

Add the new pod to your Podfile:

# Add this new dependency for FCM push notifications
pod 'CustomerIO/FirebaseWrapper'

# Keep your existing dependencies
pod 'CustomerIO/DataPipelines'
pod 'CustomerIO/MessagingPushFCM'
pod 'CustomerIO/MessagingInApp'

Then run:

pod install

2. Update import statements

Add CioFirebaseWrapper import statement in all files where you import CioMessagingPushFCM. Don’t change your other import statements:

import CioDataPipelines
import CioFirebaseWrapper // Updated
import CioMessagingPushFCM
import FirebaseCore
import FirebaseMessaging
import Foundation
import UIKit

3. Verify initialization code

Your initialization code should remain the same. The MessagingPushFCM.initialize() method continues to work exactly as before, but now it comes from the CioFirebaseWrapper package:

// This initialization code remains unchanged
MessagingPushFCM.initialize(
    withConfig: MessagingPushConfigBuilder()
        .autoFetchDeviceToken(true)
        .build()
)

Complete example

Here’s a complete example of the updated FCM setup:

import CioDataPipelines
import CioFirebaseWrapper
import CioMessagingPushFCM
import FirebaseCore
import FirebaseMessaging
import Foundation
import UIKit

@main
class AppDelegateWithCioIntegration: CioAppDelegateWrapper<AppDelegate> {}

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(
        _ application: UIApplication, 
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
    ) -> Bool {
        // Initialize Firebase
        FirebaseApp.configure()
        
        let cdpApiKey = "YOUR_CDP_API_KEY"
        let siteId = "YOUR_SITE_ID"
        
        // Configure and initialize the Customer.io SDK
        let config = SDKConfigBuilder(cdpApiKey: cdpApiKey)
            .migrationSiteId(siteId)
            .autoTrackUIKitScreenViews()
            .autoTrackDeviceAttributes(true)
  
        CustomerIO.initialize(withConfig: config.build())

        // Initialize messaging features - method remains the same
        MessagingPushFCM.initialize(
            withConfig: MessagingPushConfigBuilder()
                .autoFetchDeviceToken(true)
                .build()
        )

        return true
    }
}

Troubleshooting

Build errors after upgrade

If you encounter build errors after upgrading:

  1. Clean your build: In Xcode, go to Product > Clean Build Folder
  2. Remove old packages: If using SPM, remove the old packages and re-add them
  3. Update CocoaPods: If using CocoaPods, run pod deintegrate followed by pod install

Import errors

If you see errors related to missing imports:

  1. Verify that CioFirebaseWrapper is properly added to your project dependencies
  2. Check that the file initializing FCM functionality has both import CioFirebaseWrapper and import CioMessagingPushFCM
Copied to clipboard!
  Contents
Version