# Data Connect iOS SDK Migration Guide
source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/ios/ios-sdk-migration/index.md

This migration guide provides step-by-step instructions for migrating from Data Connect iOS SDK version 1.x to version 3.x and version 2.x to version 3.x. Follow the outlined changes carefully to ensure a smooth transition.

We recommend using the latest version of the SDK whenever possible.

## Migrating From v1.x to v3.x {#migrating-from-v1x-to-v3x}

To upgrade your app from the old v1.x Finicity Connect SDK to v3.x Mastercard Open Finance Data Connect SDK for iOS, follow these steps.

### Step 1: Update Your Pod File {#step-1-update-your-pod-file}

Update your pod file as follows:

**v1.x**

    use_frameworks!
    pod 'FinicityConnect'

**v3.x**

    use_frameworks!
    pod 'MastercardOpenBankingConnect'

Warning: CocoaPods support is deprecated.

We will continue publishing to the CocoaPods Trunk while we are able to, ideally through November 2026. However, deployments to Trunk have become unreliable, and we cannot guarantee that new versions will continue to be published there.

We strongly recommend migrating to Swift Package Manager if you have not already.

The timeline for CocoaPods becoming read-only is described here: <https://blog.cocoapods.org/CocoaPods-Specs-Repo/>

See [Using the Data Connect iOS SDK](https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/ios/ios-sdk/index.md) for details of how to install the latest SDK version via either Swift Package Manager or manually via GitHub.

### Step 2: Use the Connect Event Delegate {#step-2-use-the-connect-event-delegate}

In version 1.x, call-back functions have the following method declarations:

```swift
func openConnect(url: String) {

  let config = ConnectViewConfig (
      connectUrl: url, loaded: self.connectLoaded,
      done: self.connectDone, cancel: self.connectCancelled,
      error: self.connectError, route: self.connectRoute,
      userEvent: self.connectUserEvent )

  self.connectViewController = ConnectViewController()
  self.connectViewController.load(config: config)
}

func connectLoaded() {
  self.connectNavController = UINavigationController(
      rootViewController: self.connectViewController )
  self.connectNavController.modalPresentationStyle = .automatic
  self.present(self.connectNavController, animated: false)
}

func connectDone(_ data: NSDictionary?) {
  // Data Connect flow completed
}

func connectCancelled() {
  // Data Connect flow exited prematurely
}

func connectError(_ data: NSDictionary?) {
  // Error encountered in Data Connect flow
}

func connectRoute(_data: NSDictionary?) {
  // Data Connect route changed
}

func connectUserEvent(_ data: NSDictionary?) {
  // Data Connect user event fired in response to user action
}
```

In version 3.x, update the method names which are defined in the Data Connect event delegate as follows:

```swift
ViewController: UIViewController, ConnectEventDelegate {
  @IBOutlet var activityIndicator: UIActivityIndicatorView!

  // Declaration of View and Navigation controllers
  var connectViewController: ConnectViewController!
  var connectNavController: UINavigationController!
  var connectUrl: String?

  // For regular Data Connect flow use below openConnect function
  func openConnect(connectUrl: String) {
    self.connectViewController = ConnectViewController()
    self.connectViewController.delegate = self
    self.connectViewController.load(connectUrl!)
  }

  // For App to App Data Connect flow use below openConnect function
  func openConnect(connectUrl: String) {
    self.connectViewController = ConnectViewController()
    self.connectViewController.delegate = self
    self.connectViewController.load(connectUrl,redirectUrl: "https://example.com/connect")
  }

  // Data Connect Delegate Methods
  func onCancel(_ data: NSDictionary?) {
    // Data Connect flow exited prematurely
  }

  func onDone(_ data: NSDictionary?) {
    // Data Connect flow completed
  }

  func onError(_ data: NSDictionary?) {
    // Error encountered in Data Connect flow       
  }

  func onLoad() {
    // Data Connect User Experience loaded completely
    print("onLoad:")
    self.connectNavController = UINavigationController(rootViewController: self.connectViewController)
    if #available(iOS 13.0, *) {
      self.connectNavController.modalPresentationStyle = .automatic
      self.connectNavController.isModalInPresentation = true
    } else {
      // Fallback on earlier versions
    }
    self.connectNavController.presentationController?.delegate = self
    self.present(self.connectNavController, animated: true)
  }

  func onRoute(_ data: NSDictionary?) {
    // Data Connect route changed
  }

  func onUser(_ data: NSDictionary?) {
    // Data Connect user event fired in response to user action
  }

  func displayData(_ data: NSDictionary?) {
    print(data?.debugDescription ?? "no data in callback")
  }
}
```

If you have previously used call-back functions make sure you use the new `ConnectEventDelegate`.

### Step 3: Loading the View Controller {#step-3-loading-the-view-controller}

In version 1.x, `connectViewController` is loaded with the `ConnectViewConfig` object which contains `connectUrl` in parameter and call-back methods.

**v1.x**

```swift
func openConnect(url: String) {
  let config = ConnectViewConfig(connectUrl: url, loaded: self.connectLoaded,
    done: self.connectDone, cancel: self.connectCancelled,
    error: self.connectError, route: self.connectRoute,
    userEvent: self.connectUserEvent)

  self.connectViewController = ConnectViewController()
  self.connectViewController.load(config: config)
}

func connectLoaded() {
  self.connectNavController = UINavigationController(rootViewController: self.connectViewController)
  self.connectNavController.modalPresentationStyle = .automatic
  self.present(self.connectNavController, animated: false)
}
```

In version 3.x, `connectViewController` is loaded with `connectUrl` and call back events are handled via delegate methods. The view controller which is loading `connectViewController` must conform to `ConnectEventDelegate`.

**v3.x**

```swift
ViewController: UIViewController, ConnectEventDelegate {
// Declaration of View and Navigation controllers
    var connectViewController: ConnectViewController!
    var connectNavController: UINavigationController!
    var connectUrl: String?

   // For regular Data Connect flow use below openConnect function
    func openConnect(connectUrl: String) {
      self.connectViewController = ConnectViewController()
      self.connectViewController.delegate = self
      self.connectViewController.load(connectUrl!)
    }

   // For App to App Data Connect flow use below openConnect function
    func openConnect(connectUrl: String) {
      self.connectViewController = ConnectViewController()
      self.connectViewController.delegate = self
      self.connectViewController.load(connectUrl,redirectUrl: "https://example.com/connect")
    }

}
```

## Migrating From v2.x to v3.x {#migrating-from-v2x-to-v3x}

In version 3.x.x, an optional `redirectUrl` parameter has been added to the `connectViewController.load` method to support app to app authentication.

If you have used the `deepLinkUrl` for this previously, update your code to use `redirectUrl` instead, as this supports both deep links and app links. We recommend using app links instead of deep links.
