Accounts SDK for iOS

The Accounts SDK is a solution to ease the integration with the Alviere services.

Features

  • Account Management
  • Account Addresses Management
  • Account Dossiers Management

Requirements

  • iOS 13.0+
  • Xcode 15+
  • Swift 5.5+

Installation

Swift Package Manager

1. Add the dependency to your project. Open your project and navigate to your project’s settings. Select the tab named Swift Packages and click on the add button + at the bottom left.

image

2. Enter the url of Accounts SDK for the iOS repository (https://github.com/Alviere/alviere-accounts-ios) in the text field and click Next.

image

3. On the next screen, select the SDK version and click Next.

image

4. Select the Payments package and click Finish.

image

5. Repeat the same process for AlCore SDK (https://github.com/Alviere/alviere-core-ios). The current version is compatible with AlCore SDK version 0.9.0 and up.

CocoaPods

1. Get the latest version of CocoaPods, if you haven’t already.

2. Create the Podfile by running the following command, if you don’t have one already.

pod init

3. Add this line to your Podfile.

pod 'AccountsSDK'

4. Run the following command to install the library. Also, run this to update to newer releases in the future.

pod install

Carthage

1. Get the latest version of Carthage, if you haven’t already.

2. Add the following entries in your Cartfile:

binary https://raw.githubusercontent.com/Alviere/alviere-core-ios/master/AlCore.json
binary https://raw.githubusercontent.com/Alviere/alviere-camera-ios/master/AlCamera.json
binary https://raw.githubusercontent.com/Alviere/alviere-accounts-ios/master/AccountsSDK.json

3. Run the following command to download the latest version of the SDK.

carthage update --use-xcframeworks

4. Follow the Manual instructions below to embed the SDK into your project.

Manual

1. Get the latest versions of AccountsSDK.xcframework, its dependencies, and AlCore.xcframework and embed it into your application by dragging and dropping the files onto the Frameworks, Libraries and Embedded Content project section, as shown below.

image

2. Depending on the location of the xcframeworks on the filesystem you may need to change the Framework Search Paths build setting to avoid the error: fatal error: ‘AccountsSDK/AccountsSDK.h’ file not found. For example, the Xcode project below have it set to FRAMEWORK_SEARCH_PATHS = $(PROJECT_DIR)/../ since the xcframeworks files are shared between them and are kept in the directory that also contains the project directories.

image

Usage

To initialize the Accounts SDK for iOS, you need to set the Environment at the entry point of your application. For example, you can do this on your AppDelegate file on the application(_:,didFinishLaunchingWithOptions:) method, as shown below.

import AlCore

...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Setup Alviere SDK.
    if !AlCoreSDK.shared.setEnvironment(.sandbox) {
        print("Error initializing SDK.")
    }
    return true
}

After this setup, you just need to import the Accounts SDK for iOS on the files where you want to use the features.

import AccountsSDK

Optionally, if you will use the Add/Update/Replace Dossier features you have to adjust your app’s permissions for camera usage. You just need to add the NSCameraUsageDescription in your Info.plist file. Right-click somewhere outside the table and select Add Row. Now add the entries like below.

image

Or if you prefer to do this step with code, right-click on Info.plist and select Open As > Source Code. Add the lines below somewhere inside the <dict> </dict>.

<!-- Permission to be include in Info.plist -->
<key>NSCameraUsageDescription</key>
<string>This will let you easily take pictures of your Documents so we can verify your identity.</string>

When writing the permission request message always follow the iOS Human Design Guidelines as a guideline.

Account Management

Adopt the AccountsDelegate Protocol

This can be handled, for instance, by the view controller object that will call the user account actions.

extension ViewController : AccountsDelegate

The AccountsDelegate methods are the main communication back channel to your application for the user account management on Accounts SDK for iOS. For each action there is one method associated as follows:

  • List: didListAccounts(_:)
  • Get: didGetAccount(_:)
  • Update: didUpdateAccount(_:)

There is also a global method didHandleEvent(_,metadata:) to receive events, like errors for instance. This enables your application to gain further insight into what is going on as the user goes through the Accounts SDK flow. In case of an error you may want to display error related information to the user and have them try doing the action again.

func didHandleEvent(_ event: String, metadata: [String : String]?) {
    print("Received event: \(event)\nmetadata: \(metadata ?? [:])")
}

The event keys are defined on the Event enum and the metadata keys on Metadata enum.

List Accounts

To list accounts, use listAccounts where you will need to create a new auth_token and pass the AccountsDelegate delegate instance.

AlAccounts.shared
    .listAccounts(token: authToken,
                  query: query,
                  delegate: self)

The result of this action will return an Account array on didListAccounts(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didListAccounts(_ accounts: [Account]) {
    print("Accounts are:\n\(accounts)")
}

Get Account

To get an account, use getAccount where you will need to create a new auth_token, pass the accountUuid value, and pass the AccountsDelegate delegate instance.

AlAccounts.shared
    .getAccount(token: authToken,
                accountUuid: accountUuid,
                delegate: self)

The result of this action will return the Account details model on didGetAccount(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didGetAccount(_ account: Account) {
    print("Account is:\n\(account)")
}

Update Account

To update an account, use updateAccount where you will need to create a new auth_token, pass the accountUuid value, pass the AccountUpdateRequest model with the account data updated, and pass the AccountsDelegate delegate instance.

let data = AccountUpdateRequest( ... )

AlAccounts.shared
    .updateAccout(token: authToken,
                  accountUuid: accountUuid,
                  data: data,
                  delegate: self)

The result of this action will return the updated User model on didUpdateUserAccount(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didUpdateAccount(_ account: Account) {
    print("Updated account is:\n\(account)")
}

Account Addresses Management

Adopt the AccountAddressesDelegate Protocol

This can be handled, for instance, by the view controller object that will call the user account actions.

extension ViewController : AccountAddressesDelegate

The AccountAddressesDelegate methods are the main communication back channel to your application for the account addresses management on Accounts SDK for iOS. For each action there is one method associated as follows:

  • Create: didCreateAddress(_:)
  • List: didListAddresses(_:)
  • Update: didUpdateAddress(_:)
  • Delete: didDeleteAddress(_:)

There is also a global method didHandleEvent(_,metadata:) to receive events, like errors for instance. This enables your application to gain further insight into what is going on as the user goes through the Accounts SDK flow. In case of an error you may want to display error related information to the user and have them try doing the action again.

func didHandleEvent(_ event: String, metadata: [String : String]?) {
    print("Received event: \(event)\nmetadata: \(metadata ?? [:])")
}

The event keys are defined on the Event enum and the metadata keys on Metadata enum.

Add Account Address

To add a address to an account, use createAddress where you will need to create a new auth_token, pass the accountUuid value, pass the AccountAddressRequest model with the address data, and pass the AccountAddressesDelegate delegate instance.

let data = AccountAddressRequest( ... )

AlAccounts.shared
    .createAddress(token: authToken,
                   accountUuid: accountUuid,
                   data: data,
                   delegate: self)

The result of this action will return the newly added AccountAddress model on didCreateAddress(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didCreateAddress(_ address: AccountAddress) {
    print("New account address is:\n\(address)")
}

List Account Addresses

To get all addresses, use listAddresses where you will need to create a new auth_token, pass the accountUuid value, and pass the AccountAddressesDelegate delegate instance.

AlAccounts.shared
    .listAddresses(token: authToken,
                   accountUuid: accountUuid,
                   delegate: self)

The result of this action will return an AccountAddress array with the user addresses on didCreateAddresses(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didGetUserAddresses(_ addresses: [AccountAddress]) {
    print("Account addresses are:\n\(addresses)")
}

Update Account Address

To update an address, use updateAddress where you will need to create a new auth_token, pass the accountUuid value, pass the addressUuid value, pass the AccountAddressRequest model with the address data updated, and pass the AccountAddressDelegate delegate instance.

let data = AccountAddressRequest( ... )

AlAccounts.shared
    .updateAddress(token: authToken,
                   accountUuid: accountUuid,
                   addressUuid: addressUuid,
                   data: data,
                   delegate: self)

The result of this action will return the updated AccountAddress model on didUpdateAddress(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didUpdateAddress(_ address: AccountAddress) {
    print("Updated user address is:\n\(address)")
}

Delete Account address

In order to delete an user address, use deleteAddress where you will need to create a new auth_token, pass the accountUuid value, pass the addressUuid value, and pass the AccountAddressesDelegate delegate instance.

AlAccounts.shared
    .deleteAddress(token: authToken,
                   accountUuid: accountUuid,
                   addressUuid: addressUuid,
                   delegate: self)

The result of this action will return on didDeleteAddress() delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didDeleteAddress() {
    print("User address was deleted.")
}

Account Dossier Management

Adopt the AccountDossiersDelegate Protocol

This can be handled, for instance, by the view controller object that will call the user account actions.

extension ViewController : AccountDossiersDelegate

The AccountDossiersDelegate methods are the main communication back channel to your application for the account dossier management on Accounts SDK for iOS. For each action there is one method associated as follows:

  • Create: didCreateDossier(_:)
  • Capture: _didCaptureDocuments(:)
  • List: didListDossiers(_:)
  • Get: didGetDossier(_:)
  • Update: didUpdateDossier(_:)
  • Replace: didReplaceDossier(_:)
  • Delete: didDeleteDossier()

There is also a global method didHandleEvent(_,metadata:) to receive events, like errors for instance. This enables your application to gain further insight into what is going on as the user goes through the Accounts SDK flow. In case of an error you may want to display error related information to the user and have them try doing the action again.

func didHandleEvent(_ event: String, metadata: [String : String]?) {
    print("Received event: \(event)\nmetadata: \(metadata ?? [:])")
}

The event keys are defined on the Event enum and the metadata keys on Metadata enum.

Create Account Dossier

To create a dossier you can either do it by presenting the included UI objects or by providing the dossier data directly to createDossier method of the SDK. The result of creating a dossier will return the dossier on the didCreateDossier(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didCreateDossier(_ dossier: AccountDossier) {
    print("New dossier is:\n\(dossier)")
}
⚠️

Be aware that you should request camera permission before presenting AccountDossierViewController or it will throw an error and crash your application.

Create Account Dossier UI Presentation

Presenting the Create Dossier is as simple as creating a new auth_token and a camera_token, using it to initialize AlAccounts, and get/register the AccountDossierViewController instances. To obtain a camera token you need to call the AlCore.shared.getCameraToken method providing the user accountUUID.

var cameraToken: String?

AlCore.shared.getCameraToken(accountUUID: "accountUUID") { (token: String) in
    cameraToken = token
} failure: { (error: AlError) in
    print(error)
}

Presenting Account Dossier View Controller

From Code

To instantiate AccountDossierViewController from code, use createAccountDossierViewController where you will need to pass the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

let data = AccountDossierCaptureRequest.create( ... )

let viewController = AlAccounts.shared
    .createAccountDossierViewController(token: authToken,
                                        cameraToken: cameraToken,
                                        data: data,
                                        delegate: self,
                                        style: style)

self.navigationController?.show(viewController, sender: self)

From Storyboard

To create a AccountDossierViewController from a Storyboard or a xib you need to select your view controller. On the Custom Class section, set the Class as AccountDossierViewController and enable the Inherit Module From Target checkbox. At this point, you only need to register your view controller with AlAccounts, using the registerAccountDossierViewController and passing the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

image

If you present the view controller with a Segue you need to implement a prepare(for:, sender:) callback and then register the view controller.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let data = AccountDossierCaptureRequest.create( ... )

    AlAccounts.shared
        .registerAccountDossierViewController(token: authToken,
                                              cameraToken: cameraToken,
                                              viewController: segue.destination,
                                              data: data,
                                              delegate: self)
}

If you choose to instantiate the view controller by Storyboard ID and navigate manually, you just need to register the view controller.

let viewController = UIStoryboard(name: "Main", bundle: nil)
    .instantiateViewController(identifier: "AccountDossierViewController") as! AccountDossierViewController

let data = AccountDossierCaptureRequest.create( ... )

AlAccounts.shared
    .registerAccountDossierViewController(token: authToken,
                                          cameraToken: cameraToken,
                                          viewController: viewController,
                                          data: data,
                                          delegate: self)

self.navigationController?.show(viewController, sender: self)

Create Account Dossier Usage without UI

If you want to call the create dossier service directly, use createDossier where you will need to create a new auth_token, pass the accountUuid, the AccountDossierRequest model with the data, and the AccountDossiersDelegate delegate instance.

let model = AccountDossierRequest( ... )

AlPayments.shared
    .createDossier(token: authToken,
                   accountUuid: accountUuid,
                   data: model,
                   delegate: self)

Capture Account Dossier

To capture a dossier you need to present an instance of AccountDossierViewController either from code or from a storyboard. To start this instance you will need to pass the [Documents] value and pass the AccountDossiersCaptureDelegate delegate instance. The list of currently supported documents is defined on DocumentType enum.

⚠️

Be aware that you should request camera permission before presenting AccountDossierViewController or it will throw an error and crash your application.

The result of this action will return a [Document] with dossier details model on didCaptureDocuments(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didCaptureDocuments(_ documents: [Documents]) {
    print("Captured documents are:\n\(documents)")
}

Present from Code

To instantiate AccountDossierViewController from code, use createCaptureAccountDossierViewController where you will need to pass the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

let documents = [
    Document(typeString: DocumentType.driverLicenseFront.rawValue),
    Document(typeString: DocumentType.driverLicenseBack.rawValue),
    Document(typeString: DocumentType.selfie.rawValue)
]

let viewController = AlAccounts.shared
    .createCaptureAccountDossierViewController(cameraToken: cameraToken,
                                               data: documents,
                                               delegate: self,
                                               style: style)

self.navigationController?.show(viewController, sender: self)

Present from Storyboard

To create a AccountDossierViewController from a Storyboard or a xib you need to select your view controller. On the Custom Class section, set the Class as AccountDossierViewController and enable the Inherit Module From Target checkbox. At this point, you only need to register your view controller with AlAccounts, using the registerCaptureAccountDossierViewController and passing the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

image

If you present the view controller with a Segue you need to implement a prepare(for:, sender:) callback and then register the view controller.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let documents = [
        Document(typeString: DocumentType.driverLicenseFront.rawValue),
        Document(typeString: DocumentType.driverLicenseBack.rawValue),
        Document(typeString: DocumentType.selfie.rawValue)
    ]

    AlAccounts.shared
        .registerCaptureAccountDossierViewController(cameraToken: cameraToken,
                                                     viewController: segue.destination,
                                                     data: documents,
                                                     delegate: self)
}

If you choose to instantiate the view controller by Storyboard ID and navigate manually, you just need to register the view controller.

let viewController = UIStoryboard(name: "Main", bundle: nil)
    .instantiateViewController(identifier: "AccountDossierViewController") as! AccountDossierViewController

let documents = [
    Document(typeString: DocumentType.driverLicenseFront.rawValue),
    Document(typeString: DocumentType.driverLicenseBack.rawValue),
    Document(typeString: DocumentType.selfie.rawValue)
]

AlAccounts.shared
    .registerCaptureAccountDossierViewController(cameraToken: cameraToken,
                                                 viewController: viewController,
                                                 data: documents,
                                                 delegate: self)

self.navigationController?.show(viewController, sender: self)

List Account Dossiers

To get all account dossiers, use listDossiers where you will need to create a new auth_token, pass the accountUuid value, and pass the AccountDossiersDelegate delegate instance.

AlAccounts.shared
    .listDossiers(token: authToken,
                  accountUuid: accountUuid,
                  delegate: self)

The result of this action will return the [AccountDossier] details model on didListDossiers(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didListDossiers(_ dossiers: [AccountDossier]) {
    print("Account dossiers are:\n\(dossiers)")
}

Get Account Dossier

To get a user dossier, use getDossier where you will need to create a new auth_token, pass the accountUuid value, pass the dossierUuid value, and pass the AccountDossiersDelegate delegate instance.

AlAccounts.shared
    .getDossier(token: authToken,
                accountUuid: accountUuid,
                dossierUuid: dossieruuid,
                delegate: self)

The result of this action will return the AccountDossier details model on didGetDossier(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didGetDossier(_ dossier: AccountDossier) {
    print("Account dossier is:\n\(dossier)")
}

Update Account Dossier

To update a dossier you can either do it by presenting the included UI objects or by providing the dossier data directly to updateDossier method of the SDK. The result of updating a dossier will return the dossier on the didUpdateDossier(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didUpdateDossier(_ dossier: AccountDossier) {
    print("Updated accoubnt dossier is:\n\(dossier)")
}
⚠️

Be aware that you should request camera permission before presenting AccountDossierViewController or it will throw an error and crash your application.

Update Account Dossier UI Presentation

Presenting the Update Dossier is as simple as creating a new auth_token, using it to initialize AlAccounts, and get/register the AccountDossierViewController instances.

Presenting Account Dossier View Controller

From Code

To instantiate AccountDossierViewController from code, use createAccountDossierViewController where you will need to pass the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

let data = AccountDossierCaptureRequest.update( ... )

let viewController = AlAccounts.shared
    .createAccountDossierViewController(token: authToken,
                                        data: data,
                                        delegate: self,
                                        style: style)

self.navigationController?.show(viewController, sender: self)

From Storyboard

To update a AccountDossierViewController from a Storyboard or a xib you need to select your view controller. On the Custom Class section, set the Class as AccountDossierViewController and enable the Inherit Module From Target checkbox. At this point, you only need to register your view controller with AlAccounts, using the registerAccountDossierViewController and passing the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

image

If you present the view controller with a Segue you need to implement a prepare(for:, sender:) callback and then register the view controller.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let data = AccountDossierCaptureRequest.update( ... )

    AlAccounts.shared
        .registerAccountDossierViewController(token: authToken,
                                              viewController: segue.destination,
                                              data: data,
                                              delegate: self)
}

If you choose to instantiate the view controller by Storyboard ID and navigate manually, you just need to register the view controller.

let viewController = UIStoryboard(name: "Main", bundle: nil)
    .instantiateViewController(identifier: "AccountDossierViewController") as! AccountDossierViewController

let data = AccountDossierCaptureRequest.update( ... )

AlAccounts.shared
    .registerAccountDossierViewController(token: authToken,
                                          viewController: viewController,
                                          data: data,
                                          delegate: self)

self.navigationController?.show(viewController, sender: self)

Update Account Dossier Usage without UI

If you want to call the update dossier service directly, use updateDossier where you will need to create a new auth_token, pass the accountUuid, the AccountDossierUpdateRequest model with the data, and the AccountDossiersDelegate delegate instance.

let model = AccountDossierRequest( ... )

AlPayments.shared
    .updateDossier(token: authToken,
                   accountUuid: accountUuid,
                   dossierUuid: dossierUuid,
                   data: model,
                   delegate: self)

Replace Account Dossier

To replace a dossier you can either do it by presenting the included UI objects or by providing the dossier data directly to replaceDossier method of the SDK. The result of creating a dossier will return the dossier on the didReplaceDossier(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didReplaceDossier(_ dossier: AccountDossier) {
    print("Replaced account dossier is:\n\(dossier)")
}
⚠️

Be aware that you should request camera permission before presenting AccountDossierViewController or it will throw an error and crash your application.

Replace Account Dossier UI Presentation

Presenting the Replace Dossier is as simple as creating a new auth_token, using it to initialize AlAccounts, and get/register the AccountDossierViewController instances.

Presenting Account Dossier View Controller

From Code

To instantiate AccountDossierViewController from code, use createAccountDossierViewController where you will need to pass the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

let data = AccountDossierCaptureRequest.replace( ... )

let viewController = AlAccounts.shared
    .createAccountDossierViewController(token: authToken,
                                        data: data,
                                        delegate: self,
                                        style: style)

self.navigationController?.show(viewController, sender: self)

From Storyboard

To update a AccountDossierViewController from a Storyboard or a xib you need to select your view controller. On the Custom Class section, set the Class as AccountDossierViewController and enable the Inherit Module From Target checkbox. At this point, you only need to register your view controller with AlAccounts, using the registerAccountDossierViewController and passing the previous data. Optionally, you can also pass a UI customization object with the style overrides you want to apply.

ℹ️

Be aware that you need to present the view controller with show, presenting modally with present can produce unexpected results.

image

If you present the view controller with a Segue you need to implement a prepare(for:, sender:) callback and then register the view controller.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let data = AccountDossierCaptureRequest.replace( ... )

    AlAccounts.shared
        .registerAccountDossierViewController(token: authToken,
                                              viewController: segue.destination,
                                              data: data,
                                              delegate: self)
}

If you choose to instantiate the view controller by Storyboard ID and navigate manually, you just need to register the view controller.

let viewController = UIStoryboard(name: "Main", bundle: nil)
    .instantiateViewController(identifier: "AccountDossierViewController") as! AccountDossierViewController

let data = AccountDossierCaptureRequest.replace( ... )

AlAccounts.shared
    .registerAccountDossierViewController(token: authToken,
                                          viewController: viewController,
                                          data: data,
                                          delegate: self)

self.navigationController?.show(viewController, sender: self)

Replace Account Dossier Usage without UI

If you want to call the replace dossier service directly, use replaceDossier where you will need to create a new auth_token, pass the accountUuid, the AccountDossierUpdateRequest model with the data, and the AccountDossiersDelegate delegate instance.

let model = AccountDossierRequest( ... )

AlPayments.shared
    .replaceDossier(token: authToken,
                    accountUuid: accountUuid,
                    dossierUuid: dossierUuid,
                    data: model,
                    delegate: self)

Delete Account Dossier

In order to delete a user dossier, use deleteDossier where you will need to create a new auth_token, pass the accountUuid value, pass the dossierUuid value, and pass the AccountDossiersDelegate delegate instance.

AlAccounts.shared
    .deleteDossier(token: authToken,
                   accountUuid: accountUuid,
                   dossierUuid: dossierUuid,
                   delegate: self)

The result of this action will return on didDeleteDossier() delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didDeleteDossier() {
    print("User dossier was deleted.")
}

Alternative Usage

The SDK can also be integrated using Closures, Combine or Async/Await methods. They can be accessed respectively by:

  • Closures - A closure can be passed instead of the delegate.
  • Combine - AlAccounts.shared.combine can be used to access methods that return Combine Future objects.
  • Async/Await - AlAccounts.shared.async can be used to access async methods.

Fraud Prevention Service

The Accounts SDK has a built-in fraud prevention service. This service is automatically activated when you Update an User Account. If you already have an account created and want to activate the service on the next app run you just need to set the accountUuid on the service as the user id. For example, you can do this on your AppDelegate file on the application(_:,didFinishLaunchingWithOptions:) method, as shown below.

import AlCore

...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Setup Alviere SDK.
    if !AlCoreSDK.shared.setEnvironment(.sandbox) {
        print("Error initializing SDK.")
    }

    // Start fraud prevention service.
    AlCoreSDK.shared.startFraudPrevention()
    AlCoreSDK.shared.setUserId(accountUuid)
    return true
}

To fully enable the service you need to do a small setup by adding the add the LSApplicationQueriesSchemes array in your Info.plist file. Right-click somewhere outside the table and select Add Row. Now add the entries like below.

image

Or if you prefer to do this step with code, right-click on Info.plist and select Open As > Source Code. Add the lines below somewhere inside the <dict> </dict>.

<!-- Fraud prevention setup to be included in Info.plist -->
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>cydia</string>
</array>

Customization

The Accounts SDK for iOS provides a set of UI styling and field validation customizations to allow you to adjust the provided UI to fit your needs by setting a style model. To customize the UI, start from the default style and make the changes.

var style = LoadingStyle.getDefaultStyle()
style.backgroundColor = UIColor.white
...

Styling

Below are the styling options provided that are used to compose style models like DossierStyle.

Class Attribute Description
ViewStyle backgroundColor UIColor that affects the background color of UIView
  darkBackgroundColor UIColor that affects the background color of UIView in dark mode
TextStyle color UIColor that affects the text color of UILabel
  darkColor UIColor that affects the text color of UILabel in dark mode
  font UIFont that affects the text font of UILabel
ButtonStyle backgroundColor UIColor that affects the background color of UIButton
  darkBackgroundColor UIColor that affects the background color of UIButton in dark mode
  titleStyle TextStyle that affects the text font and color of UIButton
  cornerRadius CGFloat that controls the corner radius of UIButton
  height CGFloat that controls the height of UIButton
  margins UIEdgeInsets that controls the margins of UIButton

Text and Localization

The Accounts SDK for iOS allows you to customize the UI text. To do so, you will need to redefine the localization key that you want to change on your Localizable.strings file. The next section details a list of the current localization keys. Currently, the SDK only provides english localization.

Localization Keys

Key English Value
alviere_sdk_accounts_dossier_title_passport Passport
alviere_sdk_accounts_dossier_title_driver_license_front Driver License Front
alviere_sdk_accounts_dossier_title_driver_license_back Driver License Back
alviere_sdk_accounts_dossier_title_selfie Face
alviere_sdk_accounts_dossier_title_proof_of_address Proof of Address
alviere_sdk_accounts_dossier_title_id_document_front ID Document Front
alviere_sdk_accounts_dossier_title_id_document_back ID Document Back
alviere_sdk_accounts_dossier_title_proof_of_funds Proof of Funds
alviere_sdk_accounts_dossier_title_mc_document_front Matrícula Consular Front
alviere_sdk_accounts_dossier_title_mc_document_back Matrícula Consular Back
alviere_sdk_accounts_dossier_title_ine_document_front INE Front
alviere_sdk_accounts_dossier_title_ine_document_back INE Back
alviere_sdk_accounts_dossier_title_passport_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_driver_license_front_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_driver_license_back_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_selfie_detail Smile to automatically grab your picture.
alviere_sdk_accounts_dossier_title_proof_of_address_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_id_document_front_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_id_document_back_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_proof_of_funds_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_mc_document_front_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_mc_document_back_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_ine_document_front_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_title_ine_document_back_detail Place ID on a flat surface. Please no fingers, hands or reflections.
alviere_sdk_accounts_dossier_hint_glare Reduce glare
alviere_sdk_accounts_dossier_hint_low_contrast Low contrast
alviere_sdk_accounts_dossier_hint_busy_background Busy background
alviere_sdk_accounts_dossier_hint_not_check_back Not check back
alviere_sdk_accounts_dossier_hint_not_check_front Not check front
alviere_sdk_accounts_dossier_hint_not_identity_back Not document back
alviere_sdk_accounts_dossier_hint_not_identity_front Not document front
alviere_sdk_accounts_dossier_hint_not_passport Not passport
alviere_sdk_accounts_dossier_hint_nothing Nothing detected
alviere_sdk_accounts_dossier_hint_too_dim Too dim
alviere_sdk_accounts_dossier_hint_too_bright Too bright
alviere_sdk_accounts_dossier_hint_not_sharp Not sharp
alviere_sdk_accounts_dossier_hint_rotation Reduce rotation
alviere_sdk_accounts_dossier_hint_angle_too_large Angle too large
alviere_sdk_accounts_dossier_hint_too_close Too close
alviere_sdk_accounts_dossier_hint_too_far Too far
alviere_sdk_accounts_dossier_hint_hold_steady Hold Still
alviere_sdk_accounts_dossier_hint_data_obstructed Data obstructed
alviere_sdk_accounts_dossier_warning_not_portrait Hold device in portrait mode
alviere_sdk_accounts_dossier_step Step %d of %d
alviere_sdk_accounts_dossier_title_preview Photo preview
alviere_sdk_accounts_dossier_preview_title Accept photo?
alviere_sdk_accounts_dossier_preview_retake Cancel
alviere_sdk_accounts_dossier_preview_ok Accept
alviere_sdk_accounts_dossier_completed_title Success
alviere_sdk_accounts_dossier_uploading_title Uploading your dossier…
alviere_sdk_vo_accounts_dossier_uploading_title Uploading your dossier
alviere_sdk_vo_accounts_dossier_uploading_complete Upload finished
alviere_sdk_accounts_dossier_error_title Error
alviere_sdk_accounts_dossier_error_generic We couldn’t upload your dossier.
alviere_sdk_accounts_dossier_error_retry Try again
alviere_sdk_error_generic An error has occurred

Assets and Icons

The Accounts SDK for iOS allows you to customize the assets and icons used. You just need to create an entry on an Asset Catalog (.xcassets) file with the same key as ours. The currently available keys are below.

Key Description
dossier-error-icon Icon presented on the dossier upload error screen.