- Tech Services
Concept Development
- Industry
- Emerging Tech
- Blog
- Contact Us
10
Feb. 212.3 K
VIEWSThe 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.
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.
Please see our GitHub releases for version release notes.
Installation Using CocoaPods:
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.
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 – 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
}
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.
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
}
– 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.
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.