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

This migration guide provides step-by-step instructions for migrating from Connect Android 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 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'

### 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?) {
  // Connect flow completed
}

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

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

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

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

In version 3.x, update the method names which are defined in the 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 Connect flow use below openConnect function
  func openConnect(connectUrl: String) {
    self.connectViewController = ConnectViewController()
    self.connectViewController.delegate = self
    self.connectViewController.load(connectUrl!)
  }

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

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

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

  func onLoad() {
    // 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?) {
    // Connect route changed
  }

  func onUser(_ data: NSDictionary?) {
    // 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 Connect flow use below openConnect function
    func openConnect(connectUrl: String) {
      self.connectViewController = ConnectViewController()
      self.connectViewController.delegate = self
      self.connectViewController.load(connectUrl!)
    }
}
```

