Upgrade from 3.x to 4.0.0
UpdatedThis 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 useimport 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.
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:
- Clean your build: In Xcode, go to Product > Clean Build Folder
- Remove old packages: If using SPM, remove the old packages and re-add them
- Update CocoaPods: If using CocoaPods, run
pod deintegrate
followed bypod install
Import errors
If you see errors related to missing imports:
- Verify that
CioFirebaseWrapper
is properly added to your project dependencies - Check that the file initializing FCM functionality has both
import CioFirebaseWrapper
andimport CioMessagingPushFCM