class="nav-up">

Plaid Integration in iOS for Financial Transactions

10

Feb. 21

2.11 K

VIEWS

Overview

The Plaid Link SDK is a quick and secure way to link bank accounts to Plaid from within your iOS app Link is a drop-in framework that handles connecting a financial institution to your app (credential validation, multi-factor authentication, error handling, etc).

To get started with Plaid Link for iOS, clone the GitHub repository and try out the example application, which provides a reference implementation in Swift. You?ll want to sign up for free API keys through the Plaid Developer Dashboard to get started.

Installation

Plaid Link for iOS is an embeddable framework that is bundled and distributed within your application. There are several ways to obtain the necessary files and keep them up-to-date; we recommend using CocoaPods. Regardless of what you choose, submitting a new version of your application with the updated LinkKit.xcframework to the App Store is required.

Requirements

  1. Xcode 11.5 or greater
  2. iOS 11.0 or greater
  3. The latest version of the LinkKit.xcframework will be released around the 15th of every month. We recommend you keep up to date to provide the best Plaid Link experience in your application.

Upgrading LinkKit Framework

Please see our GitHub releases for version release notes.
Installation Using CocoaPods:

  1. If you haven’t already, install the latest version of CocoaPods.
  2. If you don’t have an existing Podfile, run the following command to create one :pod init
  3. Open podfile and add this line: pod ‘Plaid’
  4. Run this command: pod install

Manual by adding LinkKit directly

  1. Download the latest LinkKit.xcframework from GitHub.
  2. Embed LinkKit.xcframework into your application, for example by dragging and dropping the file onto the Embed Frameworks build phase as shown below.

Note: One thing which needs to be taken care of is framework search paths fatal error while manual integration of linkKit framework, which can be resolved as follows:

– Depending on the location of the LinkKit.xcframework on the filesystem you may need to change the Framework Search Paths build setting to avoid the error: fatal error: ‘LinkKit/LinkKit.h’ file not found.

For example, the LinkDemo Xcode projects have it set to FRAMEWORK_SEARCH_PATHS = $(PROJECT_DIR)/../ since the LinkKit.xcframework file is shared between them and is kept in the directory that also contains the demo project directories.

Your iOS app is almost set up and now ready to start integrating with the Plaid SDK.

Opening Link:

Before you can open Link, you need to first create a link_token. A link_token can be configured for different Link flows and is used to control much of Link’s behavior. To learn how to create a new link_token, see the API Reference entry for /link/token/create.

Create a LinkTokenConfiguration:

Each time you open Link, you will need to get a new link_token from your server and create a new LinkTokenConfiguration object with it.

var linkConfiguration = LinkTokenConfiguration(token: response?.link_token ?? “”) { success in
print(“public-token: \(success.publicToken) metadata: \(success.metadata)”)
}

Create a Handler:

Create a Handler – A Handler is a one-time use object used to open a Link session. The Handler must be retained for the duration of the Plaid SDK flow. It will also be needed to respond to OAuth universal link redirects as described in the OAuth guide.

For example:

let result = Plaid.create(configuration)
switch result {
case .failure(let error):
print(“Unable to create Plaid handler due to: \(error)”)
case .success(let handler):
self.handler = handler
}

Open Link:

Finally, open Link by calling open on the Handler object.
This will usually be done in a button’s target action.

Starting the Plaid Link for iOS experience begins with creating a link_token. Once the link_token is passed to your app, create an instance of LinkTokenConfiguration, create a Handler using Plaid.create() passing the previously created LinkTokenConfiguration instance, and call open() on the handler passing your preferred presentation method.

Presentation Method:

Plaid offers us two presentation methods
– Open using default means from the parent controller using self.

For Example:

let result = Plaid.create(linkConfiguration)
switch result {
case .failure(let error):
print(“Unable to create Plaid handler due to: \(error)”)
case .success(let handler):
handler.open(presentUsing: .viewController(self))
self.linkHandler = handler
}

– Open using custom configuration.

let result = Plaid.create(linkConfiguration)
switch result {
case .failure(let error):
print(“Unable to create Plaid handler due to: \(error)”)
case .success(let handler):
// Creating a custom handler for presenting a plaidLink controller.
let method: PresentationMethod = .custom { (vc) in
vc.modalPresentationStyle = .formSheet
self.present(vc, animated: true, completion: nil)
}
handler.open(presentUsing: method)
self.linkHandler = handler
}

After Opening Plaid Link we need to manage several cases:

– OnSuccess : A closure that is called when a user has successfully onboarded an Item. The closure should expect a single LinkSuccess argument, containing the publicToken String and a metadata of type SuccessMetadata

– OnExit : A closure that is called when a user has specifically exited the Link flow. The closure should expect a single LinkExit argument, containing an optional error and a metadata of type ExitMetadata.

– OnEvent : A closure that is called when a user reaches certain points in the Link flow. The closure should expect a single LinkEvent argument, containing an eventName enum of type EventType and a metadata of type EventMetadata.

Conclusion

Once you implement the above steps successfully run your app and you got to see screens like below:

For any query related to Plaid Integration in iOS for Financial Transactions, contact us.

Author

Lets Nurture
Posted by Lets Nurture
We use cookies to give you tailored experiences on our website.
Okay