Link is Lean’s official SDK that leverages the capabilities of modern browsers and mobile clients, such as asynchronous communication, encryption at REST, transit and much more, while giving you an optimised, customizable, conversion-optimized user journey for your users to connect their accounts.
Lean's iOS SDK is available through Swift Package Manager. To integrate Lean’s Link SDK in XCode go to File > Swift Packages > Add Package Dependency and use the URL below:
https://www.github.com/leantechnologies/link-sdk-ios-distribution
Manual installation can also be achieved by adding the .xcframework
available here to your project in XCode.
You can then import the SDK into your swift files.
import LeanSDK
You will need to initalize the LeanSDK within your Swift UI application by calling Lean.manager.setup(appToken, sandbox), version
this sets the application token and environment during runtime of your application.
You can present a Lean.manager.view
anywhere in your application, however for best performance we recommend that it be placed inside a .fullScreenCover
and set ignoresSafeArea()
so that the view displays in full screen.
You can now write and attach functions to any UI element using Lean.manager.[method]
see Methods section below
You can write your own completion blocks upon success and failure of the LinkSDK.
Errors will pass back a LeanStatus
dictionary with the following:
{status: "ERROR",method: "LINK",message: "Some message"}
// YourApp.Swiftimport SwiftUIimport LeanSDK@mainclass LeanTestAppApp: App {required init() {Lean.manager.setup(appToken: String,sandbox: true,version: "latest")}var body: some Scene {WindowGroup {ContentView()}}}
// ContentView.swiftimport SwiftUIimport LeanSDKstruct ContentView: View {@State private var isPresented = falsevar linkPermissions = [LeanPermission.Identity, LeanPermission.Accounts,LeanPermission.Transactions, LeanPermission.Balance]var body: some View {VStack {Button("Link", action: { handleLink() })}}.fullScreenCover(isPresented: $isPresented, content: {Lean.manager.view.ignoresSafeArea()})func handleLink() {Lean.manager.link(customerId: String, permissions: linkPermissions, customization: LeanCustomization?, success: {print("Entity Linked")isPresented = false}, error: { (status) inprint(status.status)print(status.message)print(status.method)isPresented = false})isPresented = true}}
Call Lean.manager.setup(appToken, sandbox, version)
during ViewDidLoad - or before attempting to make a call to the SDK.
You can now write and attach functions to any UI element using Lean.manager.[method]
see Methods section below.
Ensure that you set the presentingViewController, to the View Controller that you want the SDK to present within.
You can write your own completion blocks upon success and failure of the LinkSDK.
Errors will pass back a LeanStatus
dictionary with the following:
{status: "ERROR",method: "LINK",message: "Some message"}
// ViewController.swiftimport UIKitimport LeanSDKclass ViewController: UIViewController {var linkPermissions = [LeanPermission.Identity, LeanPermission.Accounts,LeanPermission.Transactions, LeanPermission.Balance]override func ViewDidLoad() {super.viewDidLoad()Lean.manager.setup(appToken: String, sandbox: true, version: "latest")}}@IBAction func handleLink(_sender: Any) {Lean.manager.link(presentingViewController: self,customerId: String,permissions: linkPermissions,bankId: nil,customization: LeanCustomization?,success: { status inprint("Entity Linked")}, error: { (status) inprint(status)})}
When calling Lean.manager.setup
a version is required.
Version takes a String and can point to either a specific SDK version i.e. "latest" or an alias i.e. "latest".
We recommend passing in a specific version to ensure stability in the case that a change to the SDK breaks your application.
semver
The current stable build is 1.12.2
alias
latest
is an alias for the current release. It is subject to change at relatively short notice - but does allow for any bug fixes to be shipped over the air - meaning fixes can be applied without the need to resubmit your application to the app store.
alias
next-release
is a QA version of the SDK allowing you to test the next version that will become latest
before we roll out the changes, this should only be used for development and QA purposes as it is subject to breakage without any warning.
Was this section helpful?
Lean.manager.setup(appToken: String,sandbox: true,version: "latest")
.link()
The .link
method is used to connect accounts with the Data API.
.reconnect()
The .reconnect
method is used to reauthenticate a customer account with the Data API.
.createPaymentSource()
The .createPaymentSource
method is used to connect a bank account as a payment method to your application in the Payments API.
.updatePaymentSource()
The .updatePaymentSource
method is used to authorize an additional payment destination for an existing payment source in the Payments API.
.pay()
The .pay
method is used to make a bank to bank transfer from your customer's account to your account in the Payments API.
.connect()
The .connect
method is used to enable a customer to use a single log in to create and Entity
and a PaymentSource
for use with the Data API and Payments API respectively.
Was this section helpful?
Lean.manager.link(customerId: String,permissions: ArrayOf<LeanPermission>,bankId: String?,customization: LeanCustomization?,success: () -> (),error: (status) -> ())
Lean.manager.reconnect(reconnectId: String,customization: LeanCustomization?,success: () -> (),error: (status) -> ())
Lean.manager.createPaymentSource(customerId: String,bankId: String?,customization: LeanCustomization?,success: () -> (),error: (status) -> ())
Lean.manager.updatePaymentSource(customerId: String,paymentSourceId: String,paymentDestinationId: String,customization: LeanCustomization?,success: () -> (),error: (status) -> ())
Lean.manager.pay(paymentIntentId: String,accountId: String?customization: LeanCustomization?,success: () -> (),error: (status) -> ())
Lean.manager.connect(customerId: String,permissions: ArrayOf<LeanPermission>,paymentDestinationId: String,bankId: String?customization: LeanCustomization?,success: () -> (),error: (status) -> ())
Results from the Link SDK will be sent to your server via a POST request from Lean made to the Webhook URL in the application settings.
String
The type of the webhook being received in the format of: [Object type].[action]
. When triggered by the Lean.link() call, the type will be entity.created
.
String
Description of the event that has triggered the webhook.
Object
The resource which has triggered the webhook.
Upon entity creation, this will be the entity
object:
String
The identifier you will use to reference your customer's bank entity when making API calls.
String
For your convenience, we’ll also pass the id your application uses to reference your customer.
Array
The permissions your customer granted you.
Object
Attributes related to the bank that the entity originates from.
String
The name of the bank where your user's entity and accounts exist.
String
For use with the /bank
endpoint, allows you to query data on the bank related to the entity.
String
A URL pointing to an image of the bank's logo.
String
The HEX value of the primary color the bank uses for display purposes.
String
The HEX value of the secondary color the bank uses for display purposes.
DateTime
The time at which the webhook was triggered.
// Success Example{"type": "entity.created","message": "An entity object has been created.","payload": {"id": "f08fb010-878f-407a-9ac2-a7840fb56185","app_user_id": "00001","permissions": ["transactions", "balance", "identity", "accounts"],"bank_details": {"name": "Lean Mockbank","identifier": "LEANMB1_SAU","logo": "https://cdn.leantech.me/img/banks/white-lean.png","main_color": "#1beb75","background_color": "#001E26"}},"timestamp": "2020-10-10T17:19:00.059933Z"}
We are progressively releasing customization capabilities to the Link SDK to match its UI with your application branding style. This allows customers to programmatically theme the Link SDK directly from any of the methods.
For more detailed documentation on how best to use the customization feature see our guides.
Customization guide →String
Buttons background color, active input borders, and loading spinners.
String
Elements inside any primary button such as the text, icons and the loading spinner. It is useful to boost readability of the button color.
String
CTAs and helpers.
String
Overlay containing the Link SDK dialog box.
The following color formats are supported:
Example | Format |
---|---|
"#000000" | Hex |
"#000" | Shorthand hex |
"#000000FF" | Hex with alpha |
"rgb(0, 0, 0)" | Comma separated RGB |
"rgba(0, 0, 0, 0.5)" | Comma separated RGB with Alpha |
"black" | Color name |
var customConfig = LeanCustomization(themeColor: String?,buttonTextColor: String?,linkColor: String?,overlayColor: String?)Lean.manager.connect(customerId: String,permissions: ArrayOf<LeanPermission>,paymentDestinationId: String,bankId: String?customization: customConfig,success: () -> (),error: (status) -> ())
With the Link SDK installed in your application, you can now get entity_id
s for the Data API and create payment sources and charges with the Payment API.