Remittances SDK for iOS

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

Features

  • Beneficiary Management

Requirements

  • iOS 11.0+
  • Xcode 12+
  • Swift 5.3+

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 Remittances SDK for the iOS repository (https://github.com/Alviere/alviere-remittances-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 RemittancesSDK 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 'RemittancesSDK'

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-remittances-ios/master/RemittancesSDK.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 RemittancesSDK.xcframework and AlCore.xcframework and embed them 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 RemittancesSDK.xcframework and AlCore.xcframework on the filesystem you may need to change the Framework Search Paths build setting to avoid the error: fatal error: ‘RemittancesSDK/RemittancesSDK.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 Remittances 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 Remittances SDK for iOS on the files where you want to use the features.

import RemittancesSDK

Beneficiary Management

Adopt the BeneficiaryDelegate Protocol

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

extension ViewController : BeneficiaryDelegate

The BeneficiaryDelegate methods are the main communication backchannel to your application for the beneficiary management on Remittances SDK for iOS. For each action there is one method associated as follows:

  • Create a Beneficiary: didCreateBeneficiary(_:)
  • Get a Beneficiary: didGetBeneficiary(_:)
  • Get all Beneficiaries: didGetBeneficiaries(_:)
  • Update a Beneficiary: didUpdateBeneficiary(_:)
  • Delete a Beneficiary: didDeleteBeneficiary()

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 Remittances 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 a Beneficiary

To create a beneficiary for a user, use createBeneficiary where you will need to create a new auth_token, pass the accountUuid and the CreateBeneficiaryRequest model with the data, and pass the BeneficiaryDelegate delegate instance.

let model = CreateBeneficiaryRequest( ... )

AlRemittances.shared
    .createBeneficiary(token: authToken,
                       accountUuid: accountUuid,
                       beneficiaryData: model,
                       delegate: self)

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

func didCreateBeneficiary(_ beneficiary: Beneficiary) {
    print("New beneficiary is:\n\(beneficiary)")
}

Get Beneficiary(ies)

To get all beneficiaries or a specific beneficiary card, use didGetBeneficiaries and didGetBeneficiary, respectively.

Get All Beneficiaries

To get all beneficiaries you will need to create a new auth_token, pass the accountUuid of the user and the CardDelegate delegate instance.

AlRemittances.shared
    .getBeneficiaries(token: authToken,
                      accountUuid: accountUuid,
                      delegate: self)

The result of this action will return all beneficiaries Beneficiary list on the didGetBeneficiaries(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didGetBeneficiaries(_ beneficiaries: [Beneficiary]) {
    print("Beneficiaries are:\n\(cards)")
}

Get Beneficiary

To get a beneficiary you will need to create a new auth_token, pass the accountUuid of the user, and pass the beneficiaryUuid and the CardDelegate delegate instance.

AlRemittances.shared
    .getBeneficiary(token: authToken,
                    accountUuid: accountUuid,
                    beneficiaryUuid: beneficiaryUuid,
                    delegate: self)

The result of this action will return a beneficiary Beneficiary on the didGetBeneficiary(_:) delegate method. Any errors will be returned on didHandleEvent(_,metadata:) delegate method.

func didGetBeneficiary(_ beneficiary: Beneficiary) {
    print("Beneficiary is:\n\(cards)")
}

Update a Beneficiary

To update a beneficiary for a user, use updateBeneficiary where you will need to create a new auth_token, pass the accountUuid of the user and the beneficiaryUuid, pass the UpdateBeneficiaryRequest model with the updated data, and pass the BeneficiaryDelegate delegate instance.

let beneficiaryData = UpdateBeneficiaryRequest( ... )

AlRemittances.shared
    .updateBeneficiary(token: authToken,
                       accountUuid: accountUuid,
                       beneficiaryUuid: beneficiaryUuid,
                       beneficiaryData: beneficiaryData,
                       delegate: self)

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

func didUpdateBeneficiary(_ beneficiary: Beneficiary) {
    print("Updated beneficiary is:\n\(beneficiary)")
}

Delete a Beneficiary

To delete a beneficiary for a user, use deleteBeneficiary where you will need to create a new auth_token, pass the accountUuid of the user and the beneficiaryUuid, and pass the BeneficiaryDelegate delegate instance.

AlRemittances.shared
    .deleteBeneficiary(token: authToken,
                       accountUuid: accountUuid,
                       beneficiaryUuid: beneficiaryUuid,
                       delegate: self)

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

func didDeleteBeneficiary() {
    print("Beneficiary was deleted!")
}