# Upgrade from 3.x to 4.0.0

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?[](#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[](#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[](#upgrade-process)

### 1\. Update dependencies[](#1-update-dependencies)

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

 Swift Package Manager (SPM)

#### Swift Package Manager (SPM)[](#Swift Package Manager \(SPM\))

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

 CocoaPods

#### CocoaPods[](#CocoaPods)

Add the new pod to your `Podfile`:

```ruby
# Add this new dependency for FCM push notifications
pod 'CustomerIO/CioFirebaseWrapper'

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

Then run:

```bash
pod install
```

### 2\. Update import statements[](#2-update-import-statements)

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

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

### 3\. Verify initialization code[](#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:

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

## Complete example[](#complete-example)

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

```swift
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[](#troubleshooting)

### Build errors after upgrade[](#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[](#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`